3 test_description
='test git wire-protocol version 2'
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
12 # Test protocol v2 with 'git://' transport
14 .
"$TEST_DIRECTORY"/lib-git-daemon.sh
15 start_git_daemon
--export-all --enable=receive-pack
16 daemon_parent
=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent
18 test_expect_success
'create repo to be served by git-daemon' '
19 git init "$daemon_parent" &&
20 test_commit -C "$daemon_parent" one
23 test_expect_success
'list refs with git:// using protocol v2' '
24 test_when_finished "rm -f log" &&
26 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
27 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual &&
29 # Client requested to use protocol v2
30 grep "ls-remote> .*\\\0\\\0version=2\\\0$" log &&
31 # Server responded using protocol v2
32 grep "ls-remote< version 2" log &&
34 git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
35 test_cmp expect actual
38 test_expect_success
'ref advertisement is filtered with ls-remote using protocol v2' '
39 test_when_finished "rm -f log" &&
41 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
42 ls-remote "$GIT_DAEMON_URL/parent" main >actual &&
45 $(git -C "$daemon_parent" rev-parse refs/heads/main)$(printf "\t")refs/heads/main
48 test_cmp expect actual
51 test_expect_success
'clone with git:// using protocol v2' '
52 test_when_finished "rm -f log" &&
54 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
55 clone "$GIT_DAEMON_URL/parent" daemon_child &&
57 git -C daemon_child log -1 --format=%s >actual &&
58 git -C "$daemon_parent" log -1 --format=%s >expect &&
59 test_cmp expect actual &&
61 # Client requested to use protocol v2
62 grep "clone> .*\\\0\\\0version=2\\\0$" log &&
63 # Server responded using protocol v2
64 grep "clone< version 2" log
67 test_expect_success
'fetch with git:// using protocol v2' '
68 test_when_finished "rm -f log" &&
70 test_commit -C "$daemon_parent" two &&
72 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
75 git -C daemon_child log -1 --format=%s origin/main >actual &&
76 git -C "$daemon_parent" log -1 --format=%s >expect &&
77 test_cmp expect actual &&
79 # Client requested to use protocol v2
80 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
81 # Server responded using protocol v2
82 grep "fetch< version 2" log
85 test_expect_success
'fetch by hash without tag following with protocol v2 does not list refs' '
86 test_when_finished "rm -f log" &&
88 test_commit -C "$daemon_parent" two_a &&
89 git -C "$daemon_parent" rev-parse two_a >two_a_hash &&
91 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
92 fetch --no-tags origin $(cat two_a_hash) &&
94 grep "fetch< version 2" log &&
95 ! grep "fetch> command=ls-refs" log
98 test_expect_success
'pull with git:// using protocol v2' '
99 test_when_finished "rm -f log" &&
101 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
104 git -C daemon_child log -1 --format=%s >actual &&
105 git -C "$daemon_parent" log -1 --format=%s >expect &&
106 test_cmp expect actual &&
108 # Client requested to use protocol v2
109 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
110 # Server responded using protocol v2
111 grep "fetch< version 2" log
114 test_expect_success
'push with git:// and a config of v2 does not request v2' '
115 test_when_finished "rm -f log" &&
117 # Till v2 for push is designed, make sure that if a client has
118 # protocol.version configured to use v2, that the client instead falls
121 test_commit -C daemon_child three &&
123 # Push to another branch, as the target repository has the
124 # main branch checked out and we cannot push into it.
125 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
126 push origin HEAD:client_branch &&
128 git -C daemon_child log -1 --format=%s >actual &&
129 git -C "$daemon_parent" log -1 --format=%s client_branch >expect &&
130 test_cmp expect actual &&
132 # Client requested to use protocol v2
133 ! grep "push> .*\\\0\\\0version=2\\\0$" log &&
134 # Server responded using protocol v2
135 ! grep "push< version 2" log
140 # Test protocol v2 with 'file://' transport
142 test_expect_success
'create repo to be served by file:// transport' '
143 git init file_parent &&
144 test_commit -C file_parent one
147 test_expect_success
'list refs with file:// using protocol v2' '
148 test_when_finished "rm -f log" &&
150 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
151 ls-remote --symref "file://$(pwd)/file_parent" >actual &&
153 # Server responded using protocol v2
154 grep "ls-remote< version 2" log &&
156 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
157 test_cmp expect actual
160 test_expect_success
'ref advertisement is filtered with ls-remote using protocol v2' '
161 test_when_finished "rm -f log" &&
163 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
164 ls-remote "file://$(pwd)/file_parent" main >actual &&
166 cat >expect <<-EOF &&
167 $(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main
170 test_cmp expect actual
173 test_expect_success
'server-options are sent when using ls-remote' '
174 test_when_finished "rm -f log" &&
176 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
177 ls-remote -o hello -o world "file://$(pwd)/file_parent" main >actual &&
179 cat >expect <<-EOF &&
180 $(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main
183 test_cmp expect actual &&
184 grep "server-option=hello" log &&
185 grep "server-option=world" log
188 test_expect_success
'warn if using server-option with ls-remote with legacy protocol' '
189 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
190 ls-remote -o hello -o world "file://$(pwd)/file_parent" main 2>err &&
192 test_grep "see protocol.version in" err &&
193 test_grep "server options require protocol version 2 or later" err
196 test_expect_success
'clone with file:// using protocol v2' '
197 test_when_finished "rm -f log" &&
199 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
200 clone "file://$(pwd)/file_parent" file_child &&
202 git -C file_child log -1 --format=%s >actual &&
203 git -C file_parent log -1 --format=%s >expect &&
204 test_cmp expect actual &&
206 # Server responded using protocol v2
207 grep "clone< version 2" log &&
209 # Client sent ref-prefixes to filter the ref-advertisement
210 grep "ref-prefix HEAD" log &&
211 grep "ref-prefix refs/heads/" log &&
212 grep "ref-prefix refs/tags/" log
215 test_expect_success
'clone of empty repo propagates name of default branch' '
216 test_when_finished "rm -rf file_empty_parent file_empty_child" &&
218 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
219 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
221 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
222 git -c init.defaultBranch=main -c protocol.version=2 \
223 clone "file://$(pwd)/file_empty_parent" file_empty_child &&
224 echo refs/heads/mydefaultbranch >expect &&
225 git -C file_empty_child symbolic-ref HEAD >actual &&
226 test_cmp expect actual
229 test_expect_success
'...but not if explicitly forbidden by config' '
230 test_when_finished "rm -rf file_empty_parent file_empty_child" &&
232 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
233 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
234 test_config -C file_empty_parent lsrefs.unborn ignore &&
236 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
237 git -c init.defaultBranch=main -c protocol.version=2 \
238 clone "file://$(pwd)/file_empty_parent" file_empty_child &&
239 echo refs/heads/main >expect &&
240 git -C file_empty_child symbolic-ref HEAD >actual &&
241 test_cmp expect actual
244 test_expect_success
'bare clone propagates empty default branch' '
245 test_when_finished "rm -rf file_empty_parent file_empty_child.git" &&
247 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
248 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
250 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
251 git -c init.defaultBranch=main -c protocol.version=2 \
253 "file://$(pwd)/file_empty_parent" file_empty_child.git &&
254 echo "refs/heads/mydefaultbranch" >expect &&
255 git -C file_empty_child.git symbolic-ref HEAD >actual &&
256 test_cmp expect actual
259 test_expect_success
'clone propagates unborn HEAD from non-empty repo' '
260 test_when_finished "rm -rf file_unborn_parent file_unborn_child" &&
262 git init file_unborn_parent &&
264 cd file_unborn_parent &&
265 git checkout -b branchwithstuff &&
266 test_commit --no-tag stuff &&
267 git symbolic-ref HEAD refs/heads/mydefaultbranch
270 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
271 git -c init.defaultBranch=main -c protocol.version=2 \
272 clone "file://$(pwd)/file_unborn_parent" \
273 file_unborn_child 2>stderr &&
274 echo "refs/heads/mydefaultbranch" >expect &&
275 git -C file_unborn_child symbolic-ref HEAD >actual &&
276 test_cmp expect actual &&
277 grep "warning: remote HEAD refers to nonexistent ref" stderr
280 test_expect_success
'clone propagates object-format from empty repo' '
281 test_when_finished "rm -fr src256 dst256" &&
283 echo sha256 >expect &&
284 git init --object-format=sha256 src256 &&
285 git clone src256 dst256 &&
286 git -C dst256 rev-parse --show-object-format >actual &&
288 test_cmp expect actual
291 test_expect_success
'bare clone propagates unborn HEAD from non-empty repo' '
292 test_when_finished "rm -rf file_unborn_parent file_unborn_child.git" &&
294 git init file_unborn_parent &&
296 cd file_unborn_parent &&
297 git checkout -b branchwithstuff &&
298 test_commit --no-tag stuff &&
299 git symbolic-ref HEAD refs/heads/mydefaultbranch
302 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
303 git -c init.defaultBranch=main -c protocol.version=2 \
304 clone --bare "file://$(pwd)/file_unborn_parent" \
305 file_unborn_child.git 2>stderr &&
306 echo "refs/heads/mydefaultbranch" >expect &&
307 git -C file_unborn_child.git symbolic-ref HEAD >actual &&
308 test_cmp expect actual &&
309 ! grep "warning:" stderr
312 test_expect_success
'defaulted HEAD uses remote branch if available' '
313 test_when_finished "rm -rf file_unborn_parent file_unborn_child" &&
315 git init file_unborn_parent &&
317 cd file_unborn_parent &&
318 git config lsrefs.unborn ignore &&
319 git checkout -b branchwithstuff &&
320 test_commit --no-tag stuff &&
321 git symbolic-ref HEAD refs/heads/mydefaultbranch
324 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
325 git -c init.defaultBranch=branchwithstuff -c protocol.version=2 \
326 clone "file://$(pwd)/file_unborn_parent" \
327 file_unborn_child 2>stderr &&
328 echo "refs/heads/branchwithstuff" >expect &&
329 git -C file_unborn_child symbolic-ref HEAD >actual &&
330 test_cmp expect actual &&
331 test_path_is_file file_unborn_child/stuff.t &&
332 ! grep "warning:" stderr
335 test_expect_success
'fetch with file:// using protocol v2' '
336 test_when_finished "rm -f log" &&
338 test_commit -C file_parent two &&
340 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
343 git -C file_child log -1 --format=%s origin/main >actual &&
344 git -C file_parent log -1 --format=%s >expect &&
345 test_cmp expect actual &&
347 # Server responded using protocol v2
348 grep "fetch< version 2" log
351 test_expect_success
'ref advertisement is filtered during fetch using protocol v2' '
352 test_when_finished "rm -f log" &&
354 test_commit -C file_parent three &&
355 git -C file_parent branch unwanted-branch three &&
357 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
360 git -C file_child log -1 --format=%s origin/main >actual &&
361 git -C file_parent log -1 --format=%s >expect &&
362 test_cmp expect actual &&
364 grep "refs/heads/main" log &&
365 ! grep "refs/heads/unwanted-branch" log
368 test_expect_success
'server-options are sent when fetching' '
369 test_when_finished "rm -f log" &&
371 test_commit -C file_parent four &&
373 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
374 fetch -o hello -o world origin main &&
376 git -C file_child log -1 --format=%s origin/main >actual &&
377 git -C file_parent log -1 --format=%s >expect &&
378 test_cmp expect actual &&
380 grep "server-option=hello" log &&
381 grep "server-option=world" log
384 test_expect_success
'warn if using server-option with fetch with legacy protocol' '
385 test_when_finished "rm -rf temp_child" &&
387 git init temp_child &&
389 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C temp_child -c protocol.version=0 \
390 fetch -o hello -o world "file://$(pwd)/file_parent" main 2>err &&
392 test_grep "see protocol.version in" err &&
393 test_grep "server options require protocol version 2 or later" err
396 test_expect_success
'server-options are sent when cloning' '
397 test_when_finished "rm -rf log myclone" &&
399 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
400 clone --server-option=hello --server-option=world \
401 "file://$(pwd)/file_parent" myclone &&
403 grep "server-option=hello" log &&
404 grep "server-option=world" log
407 test_expect_success
'warn if using server-option with clone with legacy protocol' '
408 test_when_finished "rm -rf myclone" &&
410 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
411 clone --server-option=hello --server-option=world \
412 "file://$(pwd)/file_parent" myclone 2>err &&
414 test_grep "see protocol.version in" err &&
415 test_grep "server options require protocol version 2 or later" err
418 test_expect_success
'upload-pack respects config using protocol v2' '
420 write_script server/.git/hook <<-\EOF &&
424 test_commit -C server one &&
426 test_config_global uploadpack.packobjectshook ./hook &&
427 test_path_is_missing server/.git/hookout &&
428 git -c protocol.version=2 clone "file://$(pwd)/server" client &&
429 test_path_is_file server/.git/hookout
432 test_expect_success
'setup filter tests' '
433 rm -rf server client &&
436 # 1 commit to create a file, and 1 commit to modify it
437 test_commit -C server message1 a.txt &&
438 test_commit -C server message2 a.txt &&
439 git -C server config protocol.version 2 &&
440 git -C server config uploadpack.allowfilter 1 &&
441 git -C server config uploadpack.allowanysha1inwant 1 &&
442 git -C server config protocol.version 2
445 test_expect_success
'partial clone' '
446 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
447 clone --filter=blob:none "file://$(pwd)/server" client &&
448 grep "version 2" trace &&
450 # Ensure that the old version of the file is missing
451 git -C client rev-list --quiet --objects --missing=print main \
453 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
455 # Ensure that client passes fsck
459 test_expect_success
'dynamically fetch missing object' '
461 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
462 cat-file -p $(git -C server rev-parse message1:a.txt) &&
463 grep "version 2" trace
466 test_expect_success
'when dynamically fetching missing object, do not list refs' '
467 ! grep "git> command=ls-refs" trace
470 test_expect_success
'partial fetch' '
471 rm -rf client "$(pwd)/trace" &&
473 SERVER="file://$(pwd)/server" &&
475 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
476 fetch --filter=blob:none "$SERVER" main:refs/heads/other &&
477 grep "version 2" trace &&
479 # Ensure that the old version of the file is missing
480 git -C client rev-list --quiet --objects --missing=print other \
482 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
484 # Ensure that client passes fsck
488 test_expect_success
'do not advertise filter if not configured to do so' '
489 SERVER="file://$(pwd)/server" &&
492 git -C server config uploadpack.allowfilter 1 &&
493 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
494 ls-remote "$SERVER" &&
495 grep "fetch=.*filter" trace &&
498 git -C server config uploadpack.allowfilter 0 &&
499 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
500 ls-remote "$SERVER" &&
501 grep "fetch=" trace >fetch_capabilities &&
502 ! grep filter fetch_capabilities
505 test_expect_success
'partial clone warns if filter is not advertised' '
507 git -C server config uploadpack.allowfilter 0 &&
508 git -c protocol.version=2 \
509 clone --filter=blob:none "file://$(pwd)/server" client 2>err &&
510 test_grep "filtering not recognized by server, ignoring" err
513 test_expect_success
'even with handcrafted request, filter does not work if not advertised' '
514 git -C server config uploadpack.allowfilter 0 &&
516 # Custom request that tries to filter even though it is not advertised.
517 test-tool pkt-line pack >in <<-EOF &&
519 object-format=$(test_oid algo)
521 want $(git -C server rev-parse main)
526 test_must_fail test-tool -C server serve-v2 --stateless-rpc \
527 <in >/dev/null 2>err &&
528 grep "unexpected line: .filter blob:none." err &&
530 # Exercise to ensure that if advertised, filter works
531 git -C server config uploadpack.allowfilter 1 &&
532 test-tool -C server serve-v2 --stateless-rpc <in >/dev/null
535 test_expect_success
'default refspec is used to filter ref when fetchcing' '
536 test_when_finished "rm -f log" &&
538 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
541 git -C file_child log -1 --format=%s three >actual &&
542 git -C file_parent log -1 --format=%s three >expect &&
543 test_cmp expect actual &&
545 grep "ref-prefix refs/heads/" log &&
546 grep "ref-prefix refs/tags/" log
549 test_expect_success
'fetch supports various ways of have lines' '
550 rm -rf server client trace &&
552 test_commit -C server dwim &&
553 TREE=$(git -C server rev-parse HEAD^{tree}) &&
554 git -C server tag exact \
555 $(git -C server commit-tree -m a "$TREE") &&
556 git -C server tag dwim-unwanted \
557 $(git -C server commit-tree -m b "$TREE") &&
558 git -C server tag exact-unwanted \
559 $(git -C server commit-tree -m c "$TREE") &&
560 git -C server tag prefix1 \
561 $(git -C server commit-tree -m d "$TREE") &&
562 git -C server tag prefix2 \
563 $(git -C server commit-tree -m e "$TREE") &&
564 git -C server tag fetch-by-sha1 \
565 $(git -C server commit-tree -m f "$TREE") &&
566 git -C server tag completely-unrelated \
567 $(git -C server commit-tree -m g "$TREE") &&
570 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
571 fetch "file://$(pwd)/server" \
574 refs/tags/prefix*:refs/tags/prefix* \
575 "$(git -C server rev-parse fetch-by-sha1)" &&
577 # Ensure that the appropriate prefixes are sent (using a sample)
578 grep "fetch> ref-prefix dwim" trace &&
579 grep "fetch> ref-prefix refs/heads/dwim" trace &&
580 grep "fetch> ref-prefix refs/tags/prefix" trace &&
582 # Ensure that the correct objects are returned
583 git -C client cat-file -e $(git -C server rev-parse dwim) &&
584 git -C client cat-file -e $(git -C server rev-parse exact) &&
585 git -C client cat-file -e $(git -C server rev-parse prefix1) &&
586 git -C client cat-file -e $(git -C server rev-parse prefix2) &&
587 git -C client cat-file -e $(git -C server rev-parse fetch-by-sha1) &&
588 test_must_fail git -C client cat-file -e \
589 $(git -C server rev-parse dwim-unwanted) &&
590 test_must_fail git -C client cat-file -e \
591 $(git -C server rev-parse exact-unwanted) &&
592 test_must_fail git -C client cat-file -e \
593 $(git -C server rev-parse completely-unrelated)
596 test_expect_success
'fetch supports include-tag and tag following' '
597 rm -rf server client trace &&
600 test_commit -C server to_fetch &&
601 git -C server tag -a annotated_tag -m message &&
604 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
605 fetch "$(pwd)/server" to_fetch:to_fetch &&
607 grep "fetch> ref-prefix to_fetch" trace &&
608 grep "fetch> ref-prefix refs/tags/" trace &&
609 grep "fetch> include-tag" trace &&
611 git -C client cat-file -e $(git -C client rev-parse annotated_tag)
614 test_expect_success
'upload-pack respects client shallows' '
615 rm -rf server client trace &&
618 test_commit -C server base &&
619 test_commit -C server client_has &&
621 git clone --depth=1 "file://$(pwd)/server" client &&
623 # Add extra commits to the client so that the whole fetch takes more
624 # than 1 request (due to negotiation)
625 test_commit_bulk -C client --id=c 32 &&
627 git -C server checkout -b newbranch base &&
628 test_commit -C server client_wants &&
630 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
631 fetch origin newbranch &&
632 # Ensure that protocol v2 is used
633 grep "fetch< version 2" trace
636 test_expect_success
'ensure that multiple fetches in same process from a shallow repo works' '
637 rm -rf server client trace &&
639 test_create_repo server &&
640 test_commit -C server one &&
641 test_commit -C server two &&
642 test_commit -C server three &&
643 git clone --shallow-exclude two "file://$(pwd)/server" client &&
645 git -C server tag -a -m "an annotated tag" twotag two &&
647 # Triggers tag following (thus, 2 fetches in one process)
648 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
649 fetch --shallow-exclude one origin &&
650 # Ensure that protocol v2 is used
651 grep "fetch< version 2" trace
654 test_expect_success
'deepen-relative' '
655 rm -rf server client trace &&
657 test_create_repo server &&
658 test_commit -C server one &&
659 test_commit -C server two &&
660 test_commit -C server three &&
661 git clone --depth 1 "file://$(pwd)/server" client &&
662 test_commit -C server four &&
664 # Sanity check that only "three" is downloaded
665 git -C client log --pretty=tformat:%s main >actual &&
666 echo three >expected &&
667 test_cmp expected actual &&
669 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
670 fetch --deepen=1 origin &&
671 # Ensure that protocol v2 is used
672 grep "fetch< version 2" trace &&
674 git -C client log --pretty=tformat:%s origin/main >actual &&
675 cat >expected <<-\EOF &&
680 test_cmp expected actual
683 setup_negotiate_only
() {
687 rm -rf "$SERVER" client
690 test_commit
-C "$SERVER" one
691 test_commit
-C "$SERVER" two
693 git clone
"$URI" client
694 test_commit
-C client three
697 test_expect_success
'usage: --negotiate-only without --negotiation-tip' '
699 URI="file://$(pwd)/server" &&
701 setup_negotiate_only "$SERVER" "$URI" &&
703 cat >err.expect <<-\EOF &&
704 fatal: --negotiate-only needs one or more --negotiation-tip=*
707 test_must_fail git -c protocol.version=2 -C client fetch \
709 origin 2>err.actual &&
710 test_cmp err.expect err.actual
713 test_expect_success
'usage: --negotiate-only with --recurse-submodules' '
714 cat >err.expect <<-\EOF &&
715 fatal: options '\''--negotiate-only'\'' and '\''--recurse-submodules'\'' cannot be used together
718 test_must_fail git -c protocol.version=2 -C client fetch \
720 --recurse-submodules \
721 origin 2>err.actual &&
722 test_cmp err.expect err.actual
725 test_expect_success
'file:// --negotiate-only' '
727 URI="file://$(pwd)/server" &&
729 setup_negotiate_only "$SERVER" "$URI" &&
731 git -c protocol.version=2 -C client fetch \
734 --negotiation-tip=$(git -C client rev-parse HEAD) \
736 COMMON=$(git -C "$SERVER" rev-parse two) &&
740 test_expect_success
'file:// --negotiate-only with protocol v0' '
742 URI="file://$(pwd)/server" &&
744 setup_negotiate_only "$SERVER" "$URI" &&
746 test_must_fail git -c protocol.version=0 -C client fetch \
749 --negotiation-tip=$(git -C client rev-parse HEAD) \
751 test_grep "negotiate-only requires protocol v2" err
754 test_expect_success
'push with custom path does not request v2' '
757 --receive-pack="env >../env.trace; git-receive-pack" \
758 origin HEAD:refs/heads/custom-push-test &&
759 test_path_is_file env.trace &&
760 ! grep ^GIT_PROTOCOL env.trace
763 test_expect_success
'fetch with custom path does request v2' '
765 git -C client fetch \
766 --upload-pack="env >../env.trace; git-upload-pack" \
768 grep ^GIT_PROTOCOL=version=2 env.trace
771 test_expect_success
'archive with custom path does not request v2' '
773 git -C client archive \
774 --exec="env >../env.trace; git-upload-archive" \
777 test_path_is_file env.trace &&
778 ! grep ^GIT_PROTOCOL env.trace
781 test_expect_success
'reject client packfile-uris if not advertised' '
783 packetize command=fetch &&
784 packetize object-format=$(test_oid algo) &&
786 packetize packfile-uris https &&
790 test_must_fail env GIT_PROTOCOL=version=2 \
791 git upload-pack client <input &&
792 test_must_fail env GIT_PROTOCOL=version=2 \
793 git -c uploadpack.blobpackfileuri \
794 upload-pack client <input &&
795 GIT_PROTOCOL=version=2 \
796 git -c uploadpack.blobpackfileuri=anything \
797 upload-pack client <input
800 # Test protocol v2 with 'http://' transport
802 .
"$TEST_DIRECTORY"/lib-httpd.sh
805 test_expect_success
'create repo to be served by http:// transport' '
806 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
807 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
808 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
811 test_expect_success
'clone with http:// using protocol v2' '
812 test_when_finished "rm -f log" &&
814 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
815 clone "$HTTPD_URL/smart/http_parent" http_child &&
817 git -C http_child log -1 --format=%s >actual &&
818 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
819 test_cmp expect actual &&
821 # Client requested to use protocol v2
822 grep "Git-Protocol: version=2" log &&
823 # Server responded using protocol v2
824 grep "git< version 2" log &&
825 # Verify that the chunked encoding sending codepath is NOT exercised
826 ! grep "Send header: Transfer-Encoding: chunked" log
829 test_expect_success
'clone repository with http:// using protocol v2 with incomplete pktline length' '
830 test_when_finished "rm -f log" &&
832 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" &&
833 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" file &&
835 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
836 clone "$HTTPD_URL/smart/incomplete_length" incomplete_length_child 2>err &&
838 # Client requested to use protocol v2
839 grep "Git-Protocol: version=2" log &&
840 # Server responded using protocol v2
841 grep "git< version 2" log &&
842 # Client reported appropriate failure
843 test_grep "bytes of length header were received" err
846 test_expect_success
'clone repository with http:// using protocol v2 with incomplete pktline body' '
847 test_when_finished "rm -f log" &&
849 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" &&
850 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" file &&
852 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
853 clone "$HTTPD_URL/smart/incomplete_body" incomplete_body_child 2>err &&
855 # Client requested to use protocol v2
856 grep "Git-Protocol: version=2" log &&
857 # Server responded using protocol v2
858 grep "git< version 2" log &&
859 # Client reported appropriate failure
860 test_grep "bytes of body are still expected" err
863 test_expect_success
'clone with http:// using protocol v2 and invalid parameters' '
864 test_when_finished "rm -f log" &&
866 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" \
867 git -c protocol.version=2 \
868 clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid &&
870 # Client requested to use protocol v2
871 grep "Git-Protocol: version=2" log &&
872 # Server responded using protocol v2
873 grep "git< version 2" log
876 test_expect_success
'clone big repository with http:// using protocol v2' '
877 test_when_finished "rm -f log" &&
879 git init "$HTTPD_DOCUMENT_ROOT_PATH/big" &&
880 # Ensure that the list of wants is greater than http.postbuffer below
881 for i in $(test_seq 1 1500)
883 # do not use here-doc, because it requires a process
885 echo "commit refs/heads/too-many-refs-$i" &&
886 echo "committer git <git@example.com> $i +0000" &&
888 echo "M 644 inline bla.txt" &&
890 echo "bla" || return 1
891 done | git -C "$HTTPD_DOCUMENT_ROOT_PATH/big" fast-import &&
893 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git \
894 -c protocol.version=2 -c http.postbuffer=65536 \
895 clone "$HTTPD_URL/smart/big" big_child &&
897 # Client requested to use protocol v2
898 grep "Git-Protocol: version=2" log &&
899 # Server responded using protocol v2
900 grep "git< version 2" log &&
901 # Verify that the chunked encoding sending codepath is exercised
902 grep "Send header: Transfer-Encoding: chunked" log
905 test_expect_success
'fetch with http:// using protocol v2' '
906 test_when_finished "rm -f log" &&
908 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
910 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
913 git -C http_child log -1 --format=%s origin/main >actual &&
914 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
915 test_cmp expect actual &&
917 # Server responded using protocol v2
918 grep "git< version 2" log
921 test_expect_success
'fetch with http:// by hash without tag following with protocol v2 does not list refs' '
922 test_when_finished "rm -f log" &&
924 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two_a &&
925 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" rev-parse two_a >two_a_hash &&
927 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
928 fetch --no-tags origin $(cat two_a_hash) &&
930 grep "fetch< version 2" log &&
931 ! grep "fetch> command=ls-refs" log
934 test_expect_success
'fetch from namespaced repo respects namespaces' '
935 test_when_finished "rm -f log" &&
937 git init "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" &&
938 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one &&
939 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two &&
940 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \
941 update-ref refs/namespaces/ns/refs/heads/main one &&
943 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
944 fetch "$HTTPD_URL/smart_namespace/nsrepo" \
945 refs/heads/main:refs/heads/theirs &&
947 # Server responded using protocol v2
948 grep "fetch< version 2" log &&
950 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect &&
951 git -C http_child rev-parse theirs >actual &&
952 test_cmp expect actual
955 test_expect_success
'ls-remote with v2 http sends only one POST' '
956 test_when_finished "rm -f log" &&
958 git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
959 GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
960 ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
961 test_cmp expect actual &&
963 grep "Send header: POST" log >posts &&
964 test_line_count = 1 posts
967 test_expect_success
'push with http:// and a config of v2 does not request v2' '
968 test_when_finished "rm -f log" &&
969 # Till v2 for push is designed, make sure that if a client has
970 # protocol.version configured to use v2, that the client instead falls
973 test_commit -C http_child three &&
975 # Push to another branch, as the target repository has the
976 # main branch checked out and we cannot push into it.
977 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
978 push origin HEAD:client_branch &&
980 git -C http_child log -1 --format=%s >actual &&
981 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
982 test_cmp expect actual &&
984 # Client did not request to use protocol v2
985 ! grep "Git-Protocol: version=2" log &&
986 # Server did not respond using protocol v2
987 ! grep "git< version 2" log
990 test_expect_success
'when server sends "ready", expect DELIM' '
991 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child &&
993 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
994 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
996 git clone "$HTTPD_URL/smart/http_parent" http_child &&
998 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
1000 # After "ready" in the acknowledgments section, pretend that a FLUSH
1001 # (0000) was sent instead of a DELIM (0001).
1002 printf "\$ready = 1 if /ready/; \$ready && s/0001/0000/" \
1003 >"$HTTPD_ROOT_PATH/one-time-perl" &&
1005 test_must_fail git -C http_child -c protocol.version=2 \
1006 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
1007 test_grep "expected packfile to be sent after .ready." err
1010 test_expect_success
'when server does not send "ready", expect FLUSH' '
1011 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log &&
1013 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1014 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
1016 git clone "$HTTPD_URL/smart/http_parent" http_child &&
1018 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
1020 # Create many commits to extend the negotiation phase across multiple
1021 # requests, so that the server does not send "ready" in the first
1023 test_commit_bulk -C http_child --id=c 32 &&
1025 # After the acknowledgments section, pretend that a DELIM
1026 # (0001) was sent instead of a FLUSH (0000).
1027 printf "\$ack = 1 if /acknowledgments/; \$ack && s/0000/0001/" \
1028 >"$HTTPD_ROOT_PATH/one-time-perl" &&
1030 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
1031 -c protocol.version=2 \
1032 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
1033 grep "fetch< .*acknowledgments" log &&
1034 ! grep "fetch< .*ready" log &&
1035 test_grep "expected no other sections to be sent after no .ready." err
1038 configure_exclusion
() {
1039 git
-C "$1" hash-object
"$2" >objh
&&
1040 git
-C "$1" pack-objects
"$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh
>packh
&&
1041 git
-C "$1" config
--add \
1042 "uploadpack.blobpackfileuri" \
1043 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1047 test_expect_success
'part of packfile response provided as URI' '
1048 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1049 rm -rf "$P" http_child log &&
1052 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1054 echo my-blob >"$P/my-blob" &&
1055 git -C "$P" add my-blob &&
1056 echo other-blob >"$P/other-blob" &&
1057 git -C "$P" add other-blob &&
1058 git -C "$P" commit -m x &&
1060 configure_exclusion "$P" my-blob >h &&
1061 configure_exclusion "$P" other-blob >h2 &&
1063 GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
1064 git -c protocol.version=2 \
1065 -c fetch.uriprotocols=http,https \
1066 clone "$HTTPD_URL/smart/http_parent" http_child &&
1068 # Ensure that my-blob and other-blob are in separate packfiles.
1069 for idx in http_child/.git/objects/pack/*.idx
1071 git verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&
1073 grep -E "^[0-9a-f]{16,} " out || :
1074 } >out.objectlist &&
1075 if test_line_count = 1 out.objectlist
1077 if grep $(cat h) out
1081 if grep $(cat h2) out
1090 # Ensure that there are exactly 3 packfiles with associated .idx
1091 ls http_child/.git/objects/pack/*.pack \
1092 http_child/.git/objects/pack/*.idx >filelist &&
1093 test_line_count = 6 filelist
1096 test_expect_success
'packfile URIs with fetch instead of clone' '
1097 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1098 rm -rf "$P" http_child log &&
1101 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1103 echo my-blob >"$P/my-blob" &&
1104 git -C "$P" add my-blob &&
1105 git -C "$P" commit -m x &&
1107 configure_exclusion "$P" my-blob >h &&
1109 git init http_child &&
1111 GIT_TEST_SIDEBAND_ALL=1 \
1112 git -C http_child -c protocol.version=2 \
1113 -c fetch.uriprotocols=http,https \
1114 fetch "$HTTPD_URL/smart/http_parent"
1117 test_expect_success
'fetching with valid packfile URI but invalid hash fails' '
1118 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1119 rm -rf "$P" http_child log &&
1122 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1124 echo my-blob >"$P/my-blob" &&
1125 git -C "$P" add my-blob &&
1126 echo other-blob >"$P/other-blob" &&
1127 git -C "$P" add other-blob &&
1128 git -C "$P" commit -m x &&
1130 configure_exclusion "$P" my-blob >h &&
1131 # Configure a URL for other-blob. Just reuse the hash of the object as
1132 # the hash of the packfile, since the hash does not matter for this
1133 # test as long as it is not the hash of the pack, and it is of the
1135 git -C "$P" hash-object other-blob >objh &&
1136 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1137 git -C "$P" config --add \
1138 "uploadpack.blobpackfileuri" \
1139 "$(cat objh) $(cat objh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1141 test_must_fail env GIT_TEST_SIDEBAND_ALL=1 \
1142 git -c protocol.version=2 \
1143 -c fetch.uriprotocols=http,https \
1144 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1145 test_grep "pack downloaded from.*does not match expected hash" err
1148 test_expect_success
'packfile-uri with transfer.fsckobjects' '
1149 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1150 rm -rf "$P" http_child log &&
1153 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1155 echo my-blob >"$P/my-blob" &&
1156 git -C "$P" add my-blob &&
1157 git -C "$P" commit -m x &&
1159 configure_exclusion "$P" my-blob >h &&
1161 sane_unset GIT_TEST_SIDEBAND_ALL &&
1162 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1163 -c fetch.uriprotocols=http,https \
1164 clone "$HTTPD_URL/smart/http_parent" http_child &&
1166 # Ensure that there are exactly 2 packfiles with associated .idx
1167 ls http_child/.git/objects/pack/*.pack \
1168 http_child/.git/objects/pack/*.idx >filelist &&
1169 test_line_count = 4 filelist
1172 test_expect_success
'packfile-uri with transfer.fsckobjects fails on bad object' '
1173 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1174 rm -rf "$P" http_child log &&
1177 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1179 cat >bogus-commit <<-EOF &&
1181 author Bugs Bunny 1234567890 +0000
1182 committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
1184 This commit object intentionally broken
1186 BOGUS=$(git -C "$P" hash-object -t commit -w --stdin --literally <bogus-commit) &&
1187 git -C "$P" branch bogus-branch "$BOGUS" &&
1189 echo my-blob >"$P/my-blob" &&
1190 git -C "$P" add my-blob &&
1191 git -C "$P" commit -m x &&
1193 configure_exclusion "$P" my-blob >h &&
1195 sane_unset GIT_TEST_SIDEBAND_ALL &&
1196 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1197 -c fetch.uriprotocols=http,https \
1198 clone "$HTTPD_URL/smart/http_parent" http_child 2>error &&
1199 test_grep "invalid author/committer line - missing email" error
1202 test_expect_success
'packfile-uri with transfer.fsckobjects succeeds when .gitmodules is separate from tree' '
1203 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1204 rm -rf "$P" http_child &&
1207 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1209 echo "[submodule libfoo]" >"$P/.gitmodules" &&
1210 echo "path = include/foo" >>"$P/.gitmodules" &&
1211 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1212 git -C "$P" add .gitmodules &&
1213 git -C "$P" commit -m x &&
1215 configure_exclusion "$P" .gitmodules >h &&
1217 sane_unset GIT_TEST_SIDEBAND_ALL &&
1218 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1219 -c fetch.uriprotocols=http,https \
1220 clone "$HTTPD_URL/smart/http_parent" http_child &&
1222 # Ensure that there are exactly 2 packfiles with associated .idx
1223 ls http_child/.git/objects/pack/*.pack \
1224 http_child/.git/objects/pack/*.idx >filelist &&
1225 test_line_count = 4 filelist
1228 test_expect_success
'packfile-uri with transfer.fsckobjects fails when .gitmodules separate from tree is invalid' '
1229 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1230 rm -rf "$P" http_child err &&
1233 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1235 echo "[submodule \"..\"]" >"$P/.gitmodules" &&
1236 echo "path = include/foo" >>"$P/.gitmodules" &&
1237 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1238 git -C "$P" add .gitmodules &&
1239 git -C "$P" commit -m x &&
1241 configure_exclusion "$P" .gitmodules >h &&
1243 sane_unset GIT_TEST_SIDEBAND_ALL &&
1244 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1245 -c fetch.uriprotocols=http,https \
1246 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1247 test_grep "disallowed submodule name" err
1250 test_expect_success
'packfile-uri path redacted in trace' '
1251 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1252 rm -rf "$P" http_child log &&
1255 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1257 echo my-blob >"$P/my-blob" &&
1258 git -C "$P" add my-blob &&
1259 git -C "$P" commit -m x &&
1261 git -C "$P" hash-object my-blob >objh &&
1262 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1263 git -C "$P" config --add \
1264 "uploadpack.blobpackfileuri" \
1265 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1267 GIT_TRACE_PACKET="$(pwd)/log" \
1268 git -c protocol.version=2 \
1269 -c fetch.uriprotocols=http,https \
1270 clone "$HTTPD_URL/smart/http_parent" http_child &&
1272 grep -F "clone< \\1$(cat packh) $HTTPD_URL/<redacted>" log
1275 test_expect_success
'packfile-uri path not redacted in trace when GIT_TRACE_REDACT=0' '
1276 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1277 rm -rf "$P" http_child log &&
1280 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1282 echo my-blob >"$P/my-blob" &&
1283 git -C "$P" add my-blob &&
1284 git -C "$P" commit -m x &&
1286 git -C "$P" hash-object my-blob >objh &&
1287 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1288 git -C "$P" config --add \
1289 "uploadpack.blobpackfileuri" \
1290 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1292 GIT_TRACE_PACKET="$(pwd)/log" \
1293 GIT_TRACE_REDACT=0 \
1294 git -c protocol.version=2 \
1295 -c fetch.uriprotocols=http,https \
1296 clone "$HTTPD_URL/smart/http_parent" http_child &&
1298 grep -F "clone< \\1$(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" log
1301 test_expect_success
'http:// --negotiate-only' '
1302 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1303 URI="$HTTPD_URL/smart/server" &&
1305 setup_negotiate_only "$SERVER" "$URI" &&
1307 git -c protocol.version=2 -C client fetch \
1310 --negotiation-tip=$(git -C client rev-parse HEAD) \
1312 COMMON=$(git -C "$SERVER" rev-parse two) &&
1316 test_expect_success
'http:// --negotiate-only without wait-for-done support' '
1318 URI="$HTTPD_URL/one_time_perl/server" &&
1320 setup_negotiate_only "$SERVER" "$URI" &&
1322 echo "s/ wait-for-done/ xxxx-xxx-xxxx/" \
1323 >"$HTTPD_ROOT_PATH/one-time-perl" &&
1325 test_must_fail git -c protocol.version=2 -C client fetch \
1328 --negotiation-tip=$(git -C client rev-parse HEAD) \
1330 test_grep "server does not support wait-for-done" err
1333 test_expect_success
'http:// --negotiate-only with protocol v0' '
1334 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1335 URI="$HTTPD_URL/smart/server" &&
1337 setup_negotiate_only "$SERVER" "$URI" &&
1339 test_must_fail git -c protocol.version=0 -C client fetch \
1342 --negotiation-tip=$(git -C client rev-parse HEAD) \
1344 test_grep "negotiate-only requires protocol v2" err
1347 # DO NOT add non-httpd-specific tests here, because the last part of this
1348 # test script is only executed when httpd is available and enabled.