Merge branch 'tb/commit-graph-genv2-upgrade-fix' into maint
[git/debian.git] / t / t5702-protocol-v2.sh
blob5d42a355a8b81b0f2087eeb8302eb7859c04553c
1 #!/bin/sh
3 test_description='test git wire-protocol version 2'
5 TEST_NO_CREATE_REPO=1
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 . ./test-lib.sh
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 &&
44 cat >expect <<-EOF &&
45 $(git -C "$daemon_parent" rev-parse refs/heads/main)$(printf "\t")refs/heads/main
46 EOF
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 \
73 fetch &&
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 \
102 pull &&
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
119 # back and uses v0.
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
138 stop_git_daemon
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_i18ngrep "see protocol.version in" err &&
193 test_i18ngrep "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 grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
227 test_expect_success '...but not if explicitly forbidden by config' '
228 test_when_finished "rm -rf file_empty_parent file_empty_child" &&
230 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
231 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
232 test_config -C file_empty_parent lsrefs.unborn ignore &&
234 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
235 git -c init.defaultBranch=main -c protocol.version=2 \
236 clone "file://$(pwd)/file_empty_parent" file_empty_child &&
237 ! grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
240 test_expect_success 'bare clone propagates empty default branch' '
241 test_when_finished "rm -rf file_empty_parent file_empty_child.git" &&
243 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
244 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
246 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
247 git -c init.defaultBranch=main -c protocol.version=2 \
248 clone --bare \
249 "file://$(pwd)/file_empty_parent" file_empty_child.git &&
250 grep "refs/heads/mydefaultbranch" file_empty_child.git/HEAD
253 test_expect_success 'clone propagates unborn HEAD from non-empty repo' '
254 test_when_finished "rm -rf file_unborn_parent file_unborn_child" &&
256 git init file_unborn_parent &&
258 cd file_unborn_parent &&
259 git checkout -b branchwithstuff &&
260 test_commit --no-tag stuff &&
261 git symbolic-ref HEAD refs/heads/mydefaultbranch
262 ) &&
264 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
265 git -c init.defaultBranch=main -c protocol.version=2 \
266 clone "file://$(pwd)/file_unborn_parent" \
267 file_unborn_child 2>stderr &&
268 grep "refs/heads/mydefaultbranch" file_unborn_child/.git/HEAD &&
269 grep "warning: remote HEAD refers to nonexistent ref" stderr
272 test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' '
273 test_when_finished "rm -rf file_unborn_parent file_unborn_child.git" &&
275 git init file_unborn_parent &&
277 cd file_unborn_parent &&
278 git checkout -b branchwithstuff &&
279 test_commit --no-tag stuff &&
280 git symbolic-ref HEAD refs/heads/mydefaultbranch
281 ) &&
283 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
284 git -c init.defaultBranch=main -c protocol.version=2 \
285 clone --bare "file://$(pwd)/file_unborn_parent" \
286 file_unborn_child.git 2>stderr &&
287 grep "refs/heads/mydefaultbranch" file_unborn_child.git/HEAD &&
288 ! grep "warning:" stderr
291 test_expect_success 'defaulted HEAD uses remote branch if available' '
292 test_when_finished "rm -rf file_unborn_parent file_unborn_child" &&
294 git init file_unborn_parent &&
296 cd file_unborn_parent &&
297 git config lsrefs.unborn ignore &&
298 git checkout -b branchwithstuff &&
299 test_commit --no-tag stuff &&
300 git symbolic-ref HEAD refs/heads/mydefaultbranch
301 ) &&
303 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
304 git -c init.defaultBranch=branchwithstuff -c protocol.version=2 \
305 clone "file://$(pwd)/file_unborn_parent" \
306 file_unborn_child 2>stderr &&
307 grep "refs/heads/branchwithstuff" file_unborn_child/.git/HEAD &&
308 test_path_is_file file_unborn_child/stuff.t &&
309 ! grep "warning:" stderr
312 test_expect_success 'fetch with file:// using protocol v2' '
313 test_when_finished "rm -f log" &&
315 test_commit -C file_parent two &&
317 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
318 fetch origin &&
320 git -C file_child log -1 --format=%s origin/main >actual &&
321 git -C file_parent log -1 --format=%s >expect &&
322 test_cmp expect actual &&
324 # Server responded using protocol v2
325 grep "fetch< version 2" log
328 test_expect_success 'ref advertisement is filtered during fetch using protocol v2' '
329 test_when_finished "rm -f log" &&
331 test_commit -C file_parent three &&
332 git -C file_parent branch unwanted-branch three &&
334 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
335 fetch origin main &&
337 git -C file_child log -1 --format=%s origin/main >actual &&
338 git -C file_parent log -1 --format=%s >expect &&
339 test_cmp expect actual &&
341 grep "refs/heads/main" log &&
342 ! grep "refs/heads/unwanted-branch" log
345 test_expect_success 'server-options are sent when fetching' '
346 test_when_finished "rm -f log" &&
348 test_commit -C file_parent four &&
350 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
351 fetch -o hello -o world origin main &&
353 git -C file_child log -1 --format=%s origin/main >actual &&
354 git -C file_parent log -1 --format=%s >expect &&
355 test_cmp expect actual &&
357 grep "server-option=hello" log &&
358 grep "server-option=world" log
361 test_expect_success 'warn if using server-option with fetch with legacy protocol' '
362 test_when_finished "rm -rf temp_child" &&
364 git init temp_child &&
366 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C temp_child -c protocol.version=0 \
367 fetch -o hello -o world "file://$(pwd)/file_parent" main 2>err &&
369 test_i18ngrep "see protocol.version in" err &&
370 test_i18ngrep "server options require protocol version 2 or later" err
373 test_expect_success 'server-options are sent when cloning' '
374 test_when_finished "rm -rf log myclone" &&
376 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
377 clone --server-option=hello --server-option=world \
378 "file://$(pwd)/file_parent" myclone &&
380 grep "server-option=hello" log &&
381 grep "server-option=world" log
384 test_expect_success 'warn if using server-option with clone with legacy protocol' '
385 test_when_finished "rm -rf myclone" &&
387 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
388 clone --server-option=hello --server-option=world \
389 "file://$(pwd)/file_parent" myclone 2>err &&
391 test_i18ngrep "see protocol.version in" err &&
392 test_i18ngrep "server options require protocol version 2 or later" err
395 test_expect_success 'upload-pack respects config using protocol v2' '
396 git init server &&
397 write_script server/.git/hook <<-\EOF &&
398 touch hookout
399 "$@"
401 test_commit -C server one &&
403 test_config_global uploadpack.packobjectshook ./hook &&
404 test_path_is_missing server/.git/hookout &&
405 git -c protocol.version=2 clone "file://$(pwd)/server" client &&
406 test_path_is_file server/.git/hookout
409 test_expect_success 'setup filter tests' '
410 rm -rf server client &&
411 git init server &&
413 # 1 commit to create a file, and 1 commit to modify it
414 test_commit -C server message1 a.txt &&
415 test_commit -C server message2 a.txt &&
416 git -C server config protocol.version 2 &&
417 git -C server config uploadpack.allowfilter 1 &&
418 git -C server config uploadpack.allowanysha1inwant 1 &&
419 git -C server config protocol.version 2
422 test_expect_success 'partial clone' '
423 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
424 clone --filter=blob:none "file://$(pwd)/server" client &&
425 grep "version 2" trace &&
427 # Ensure that the old version of the file is missing
428 git -C client rev-list --quiet --objects --missing=print main \
429 >observed.oids &&
430 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
432 # Ensure that client passes fsck
433 git -C client fsck
436 test_expect_success 'dynamically fetch missing object' '
437 rm "$(pwd)/trace" &&
438 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
439 cat-file -p $(git -C server rev-parse message1:a.txt) &&
440 grep "version 2" trace
443 test_expect_success 'when dynamically fetching missing object, do not list refs' '
444 ! grep "git> command=ls-refs" trace
447 test_expect_success 'partial fetch' '
448 rm -rf client "$(pwd)/trace" &&
449 git init client &&
450 SERVER="file://$(pwd)/server" &&
452 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
453 fetch --filter=blob:none "$SERVER" main:refs/heads/other &&
454 grep "version 2" trace &&
456 # Ensure that the old version of the file is missing
457 git -C client rev-list --quiet --objects --missing=print other \
458 >observed.oids &&
459 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
461 # Ensure that client passes fsck
462 git -C client fsck
465 test_expect_success 'do not advertise filter if not configured to do so' '
466 SERVER="file://$(pwd)/server" &&
468 rm "$(pwd)/trace" &&
469 git -C server config uploadpack.allowfilter 1 &&
470 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
471 ls-remote "$SERVER" &&
472 grep "fetch=.*filter" trace &&
474 rm "$(pwd)/trace" &&
475 git -C server config uploadpack.allowfilter 0 &&
476 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
477 ls-remote "$SERVER" &&
478 grep "fetch=" trace >fetch_capabilities &&
479 ! grep filter fetch_capabilities
482 test_expect_success 'partial clone warns if filter is not advertised' '
483 rm -rf client &&
484 git -C server config uploadpack.allowfilter 0 &&
485 git -c protocol.version=2 \
486 clone --filter=blob:none "file://$(pwd)/server" client 2>err &&
487 test_i18ngrep "filtering not recognized by server, ignoring" err
490 test_expect_success 'even with handcrafted request, filter does not work if not advertised' '
491 git -C server config uploadpack.allowfilter 0 &&
493 # Custom request that tries to filter even though it is not advertised.
494 test-tool pkt-line pack >in <<-EOF &&
495 command=fetch
496 object-format=$(test_oid algo)
497 0001
498 want $(git -C server rev-parse main)
499 filter blob:none
500 0000
503 test_must_fail test-tool -C server serve-v2 --stateless-rpc \
504 <in >/dev/null 2>err &&
505 grep "unexpected line: .filter blob:none." err &&
507 # Exercise to ensure that if advertised, filter works
508 git -C server config uploadpack.allowfilter 1 &&
509 test-tool -C server serve-v2 --stateless-rpc <in >/dev/null
512 test_expect_success 'default refspec is used to filter ref when fetchcing' '
513 test_when_finished "rm -f log" &&
515 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
516 fetch origin &&
518 git -C file_child log -1 --format=%s three >actual &&
519 git -C file_parent log -1 --format=%s three >expect &&
520 test_cmp expect actual &&
522 grep "ref-prefix refs/heads/" log &&
523 grep "ref-prefix refs/tags/" log
526 test_expect_success 'fetch supports various ways of have lines' '
527 rm -rf server client trace &&
528 git init server &&
529 test_commit -C server dwim &&
530 TREE=$(git -C server rev-parse HEAD^{tree}) &&
531 git -C server tag exact \
532 $(git -C server commit-tree -m a "$TREE") &&
533 git -C server tag dwim-unwanted \
534 $(git -C server commit-tree -m b "$TREE") &&
535 git -C server tag exact-unwanted \
536 $(git -C server commit-tree -m c "$TREE") &&
537 git -C server tag prefix1 \
538 $(git -C server commit-tree -m d "$TREE") &&
539 git -C server tag prefix2 \
540 $(git -C server commit-tree -m e "$TREE") &&
541 git -C server tag fetch-by-sha1 \
542 $(git -C server commit-tree -m f "$TREE") &&
543 git -C server tag completely-unrelated \
544 $(git -C server commit-tree -m g "$TREE") &&
546 git init client &&
547 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
548 fetch "file://$(pwd)/server" \
549 dwim \
550 refs/tags/exact \
551 refs/tags/prefix*:refs/tags/prefix* \
552 "$(git -C server rev-parse fetch-by-sha1)" &&
554 # Ensure that the appropriate prefixes are sent (using a sample)
555 grep "fetch> ref-prefix dwim" trace &&
556 grep "fetch> ref-prefix refs/heads/dwim" trace &&
557 grep "fetch> ref-prefix refs/tags/prefix" trace &&
559 # Ensure that the correct objects are returned
560 git -C client cat-file -e $(git -C server rev-parse dwim) &&
561 git -C client cat-file -e $(git -C server rev-parse exact) &&
562 git -C client cat-file -e $(git -C server rev-parse prefix1) &&
563 git -C client cat-file -e $(git -C server rev-parse prefix2) &&
564 git -C client cat-file -e $(git -C server rev-parse fetch-by-sha1) &&
565 test_must_fail git -C client cat-file -e \
566 $(git -C server rev-parse dwim-unwanted) &&
567 test_must_fail git -C client cat-file -e \
568 $(git -C server rev-parse exact-unwanted) &&
569 test_must_fail git -C client cat-file -e \
570 $(git -C server rev-parse completely-unrelated)
573 test_expect_success 'fetch supports include-tag and tag following' '
574 rm -rf server client trace &&
575 git init server &&
577 test_commit -C server to_fetch &&
578 git -C server tag -a annotated_tag -m message &&
580 git init client &&
581 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
582 fetch "$(pwd)/server" to_fetch:to_fetch &&
584 grep "fetch> ref-prefix to_fetch" trace &&
585 grep "fetch> ref-prefix refs/tags/" trace &&
586 grep "fetch> include-tag" trace &&
588 git -C client cat-file -e $(git -C client rev-parse annotated_tag)
591 test_expect_success 'upload-pack respects client shallows' '
592 rm -rf server client trace &&
594 git init server &&
595 test_commit -C server base &&
596 test_commit -C server client_has &&
598 git clone --depth=1 "file://$(pwd)/server" client &&
600 # Add extra commits to the client so that the whole fetch takes more
601 # than 1 request (due to negotiation)
602 test_commit_bulk -C client --id=c 32 &&
604 git -C server checkout -b newbranch base &&
605 test_commit -C server client_wants &&
607 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
608 fetch origin newbranch &&
609 # Ensure that protocol v2 is used
610 grep "fetch< version 2" trace
613 test_expect_success 'ensure that multiple fetches in same process from a shallow repo works' '
614 rm -rf server client trace &&
616 test_create_repo server &&
617 test_commit -C server one &&
618 test_commit -C server two &&
619 test_commit -C server three &&
620 git clone --shallow-exclude two "file://$(pwd)/server" client &&
622 git -C server tag -a -m "an annotated tag" twotag two &&
624 # Triggers tag following (thus, 2 fetches in one process)
625 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
626 fetch --shallow-exclude one origin &&
627 # Ensure that protocol v2 is used
628 grep "fetch< version 2" trace
631 test_expect_success 'deepen-relative' '
632 rm -rf server client trace &&
634 test_create_repo server &&
635 test_commit -C server one &&
636 test_commit -C server two &&
637 test_commit -C server three &&
638 git clone --depth 1 "file://$(pwd)/server" client &&
639 test_commit -C server four &&
641 # Sanity check that only "three" is downloaded
642 git -C client log --pretty=tformat:%s main >actual &&
643 echo three >expected &&
644 test_cmp expected actual &&
646 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
647 fetch --deepen=1 origin &&
648 # Ensure that protocol v2 is used
649 grep "fetch< version 2" trace &&
651 git -C client log --pretty=tformat:%s origin/main >actual &&
652 cat >expected <<-\EOF &&
653 four
654 three
657 test_cmp expected actual
660 setup_negotiate_only () {
661 SERVER="$1"
662 URI="$2"
664 rm -rf "$SERVER" client
666 git init "$SERVER"
667 test_commit -C "$SERVER" one
668 test_commit -C "$SERVER" two
670 git clone "$URI" client
671 test_commit -C client three
674 test_expect_success 'usage: --negotiate-only without --negotiation-tip' '
675 SERVER="server" &&
676 URI="file://$(pwd)/server" &&
678 setup_negotiate_only "$SERVER" "$URI" &&
680 cat >err.expect <<-\EOF &&
681 fatal: --negotiate-only needs one or more --negotiation-tip=*
684 test_must_fail git -c protocol.version=2 -C client fetch \
685 --negotiate-only \
686 origin 2>err.actual &&
687 test_cmp err.expect err.actual
690 test_expect_success 'usage: --negotiate-only with --recurse-submodules' '
691 cat >err.expect <<-\EOF &&
692 fatal: options '\''--negotiate-only'\'' and '\''--recurse-submodules'\'' cannot be used together
695 test_must_fail git -c protocol.version=2 -C client fetch \
696 --negotiate-only \
697 --recurse-submodules \
698 origin 2>err.actual &&
699 test_cmp err.expect err.actual
702 test_expect_success 'file:// --negotiate-only' '
703 SERVER="server" &&
704 URI="file://$(pwd)/server" &&
706 setup_negotiate_only "$SERVER" "$URI" &&
708 git -c protocol.version=2 -C client fetch \
709 --no-tags \
710 --negotiate-only \
711 --negotiation-tip=$(git -C client rev-parse HEAD) \
712 origin >out &&
713 COMMON=$(git -C "$SERVER" rev-parse two) &&
714 grep "$COMMON" out
717 test_expect_success 'file:// --negotiate-only with protocol v0' '
718 SERVER="server" &&
719 URI="file://$(pwd)/server" &&
721 setup_negotiate_only "$SERVER" "$URI" &&
723 test_must_fail git -c protocol.version=0 -C client fetch \
724 --no-tags \
725 --negotiate-only \
726 --negotiation-tip=$(git -C client rev-parse HEAD) \
727 origin 2>err &&
728 test_i18ngrep "negotiate-only requires protocol v2" err
731 # Test protocol v2 with 'http://' transport
733 . "$TEST_DIRECTORY"/lib-httpd.sh
734 start_httpd
736 test_expect_success 'create repo to be served by http:// transport' '
737 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
738 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
739 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
742 test_expect_success 'clone with http:// using protocol v2' '
743 test_when_finished "rm -f log" &&
745 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
746 clone "$HTTPD_URL/smart/http_parent" http_child &&
748 git -C http_child log -1 --format=%s >actual &&
749 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
750 test_cmp expect actual &&
752 # Client requested to use protocol v2
753 grep "Git-Protocol: version=2" log &&
754 # Server responded using protocol v2
755 grep "git< version 2" log &&
756 # Verify that the chunked encoding sending codepath is NOT exercised
757 ! grep "Send header: Transfer-Encoding: chunked" log
760 test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline length' '
761 test_when_finished "rm -f log" &&
763 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" &&
764 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" file &&
766 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
767 clone "$HTTPD_URL/smart/incomplete_length" incomplete_length_child 2>err &&
769 # Client requested to use protocol v2
770 grep "Git-Protocol: version=2" log &&
771 # Server responded using protocol v2
772 grep "git< version 2" log &&
773 # Client reported appropriate failure
774 test_i18ngrep "bytes of length header were received" err
777 test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline body' '
778 test_when_finished "rm -f log" &&
780 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" &&
781 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" file &&
783 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
784 clone "$HTTPD_URL/smart/incomplete_body" incomplete_body_child 2>err &&
786 # Client requested to use protocol v2
787 grep "Git-Protocol: version=2" log &&
788 # Server responded using protocol v2
789 grep "git< version 2" log &&
790 # Client reported appropriate failure
791 test_i18ngrep "bytes of body are still expected" err
794 test_expect_success 'clone with http:// using protocol v2 and invalid parameters' '
795 test_when_finished "rm -f log" &&
797 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" \
798 git -c protocol.version=2 \
799 clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid &&
801 # Client requested to use protocol v2
802 grep "Git-Protocol: version=2" log &&
803 # Server responded using protocol v2
804 grep "git< version 2" log
807 test_expect_success 'clone big repository with http:// using protocol v2' '
808 test_when_finished "rm -f log" &&
810 git init "$HTTPD_DOCUMENT_ROOT_PATH/big" &&
811 # Ensure that the list of wants is greater than http.postbuffer below
812 for i in $(test_seq 1 1500)
814 # do not use here-doc, because it requires a process
815 # per loop iteration
816 echo "commit refs/heads/too-many-refs-$i" &&
817 echo "committer git <git@example.com> $i +0000" &&
818 echo "data 0" &&
819 echo "M 644 inline bla.txt" &&
820 echo "data 4" &&
821 echo "bla" || return 1
822 done | git -C "$HTTPD_DOCUMENT_ROOT_PATH/big" fast-import &&
824 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git \
825 -c protocol.version=2 -c http.postbuffer=65536 \
826 clone "$HTTPD_URL/smart/big" big_child &&
828 # Client requested to use protocol v2
829 grep "Git-Protocol: version=2" log &&
830 # Server responded using protocol v2
831 grep "git< version 2" log &&
832 # Verify that the chunked encoding sending codepath is exercised
833 grep "Send header: Transfer-Encoding: chunked" log
836 test_expect_success 'fetch with http:// using protocol v2' '
837 test_when_finished "rm -f log" &&
839 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
841 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
842 fetch &&
844 git -C http_child log -1 --format=%s origin/main >actual &&
845 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
846 test_cmp expect actual &&
848 # Server responded using protocol v2
849 grep "git< version 2" log
852 test_expect_success 'fetch with http:// by hash without tag following with protocol v2 does not list refs' '
853 test_when_finished "rm -f log" &&
855 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two_a &&
856 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" rev-parse two_a >two_a_hash &&
858 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
859 fetch --no-tags origin $(cat two_a_hash) &&
861 grep "fetch< version 2" log &&
862 ! grep "fetch> command=ls-refs" log
865 test_expect_success 'fetch from namespaced repo respects namespaces' '
866 test_when_finished "rm -f log" &&
868 git init "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" &&
869 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one &&
870 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two &&
871 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \
872 update-ref refs/namespaces/ns/refs/heads/main one &&
874 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
875 fetch "$HTTPD_URL/smart_namespace/nsrepo" \
876 refs/heads/main:refs/heads/theirs &&
878 # Server responded using protocol v2
879 grep "fetch< version 2" log &&
881 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect &&
882 git -C http_child rev-parse theirs >actual &&
883 test_cmp expect actual
886 test_expect_success 'ls-remote with v2 http sends only one POST' '
887 test_when_finished "rm -f log" &&
889 git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
890 GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
891 ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
892 test_cmp expect actual &&
894 grep "Send header: POST" log >posts &&
895 test_line_count = 1 posts
898 test_expect_success 'push with http:// and a config of v2 does not request v2' '
899 test_when_finished "rm -f log" &&
900 # Till v2 for push is designed, make sure that if a client has
901 # protocol.version configured to use v2, that the client instead falls
902 # back and uses v0.
904 test_commit -C http_child three &&
906 # Push to another branch, as the target repository has the
907 # main branch checked out and we cannot push into it.
908 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
909 push origin HEAD:client_branch &&
911 git -C http_child log -1 --format=%s >actual &&
912 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
913 test_cmp expect actual &&
915 # Client did not request to use protocol v2
916 ! grep "Git-Protocol: version=2" log &&
917 # Server did not respond using protocol v2
918 ! grep "git< version 2" log
921 test_expect_success 'when server sends "ready", expect DELIM' '
922 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child &&
924 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
925 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
927 git clone "$HTTPD_URL/smart/http_parent" http_child &&
929 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
931 # After "ready" in the acknowledgments section, pretend that a FLUSH
932 # (0000) was sent instead of a DELIM (0001).
933 printf "\$ready = 1 if /ready/; \$ready && s/0001/0000/" \
934 >"$HTTPD_ROOT_PATH/one-time-perl" &&
936 test_must_fail git -C http_child -c protocol.version=2 \
937 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
938 test_i18ngrep "expected packfile to be sent after .ready." err
941 test_expect_success 'when server does not send "ready", expect FLUSH' '
942 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log &&
944 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
945 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
947 git clone "$HTTPD_URL/smart/http_parent" http_child &&
949 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
951 # Create many commits to extend the negotiation phase across multiple
952 # requests, so that the server does not send "ready" in the first
953 # request.
954 test_commit_bulk -C http_child --id=c 32 &&
956 # After the acknowledgments section, pretend that a DELIM
957 # (0001) was sent instead of a FLUSH (0000).
958 printf "\$ack = 1 if /acknowledgments/; \$ack && s/0000/0001/" \
959 >"$HTTPD_ROOT_PATH/one-time-perl" &&
961 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
962 -c protocol.version=2 \
963 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
964 grep "fetch< .*acknowledgments" log &&
965 ! grep "fetch< .*ready" log &&
966 test_i18ngrep "expected no other sections to be sent after no .ready." err
969 configure_exclusion () {
970 git -C "$1" hash-object "$2" >objh &&
971 git -C "$1" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
972 git -C "$1" config --add \
973 "uploadpack.blobpackfileuri" \
974 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
975 cat objh
978 test_expect_success 'part of packfile response provided as URI' '
979 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
980 rm -rf "$P" http_child log &&
982 git init "$P" &&
983 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
985 echo my-blob >"$P/my-blob" &&
986 git -C "$P" add my-blob &&
987 echo other-blob >"$P/other-blob" &&
988 git -C "$P" add other-blob &&
989 git -C "$P" commit -m x &&
991 configure_exclusion "$P" my-blob >h &&
992 configure_exclusion "$P" other-blob >h2 &&
994 GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
995 git -c protocol.version=2 \
996 -c fetch.uriprotocols=http,https \
997 clone "$HTTPD_URL/smart/http_parent" http_child &&
999 # Ensure that my-blob and other-blob are in separate packfiles.
1000 for idx in http_child/.git/objects/pack/*.idx
1002 git verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&
1004 grep "^[0-9a-f]\{16,\} " out || :
1005 } >out.objectlist &&
1006 if test_line_count = 1 out.objectlist
1007 then
1008 if grep $(cat h) out
1009 then
1010 >hfound
1011 fi &&
1012 if grep $(cat h2) out
1013 then
1014 >h2found
1016 fi || return 1
1017 done &&
1018 test -f hfound &&
1019 test -f h2found &&
1021 # Ensure that there are exactly 3 packfiles with associated .idx
1022 ls http_child/.git/objects/pack/*.pack \
1023 http_child/.git/objects/pack/*.idx >filelist &&
1024 test_line_count = 6 filelist
1027 test_expect_success 'packfile URIs with fetch instead of clone' '
1028 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1029 rm -rf "$P" http_child log &&
1031 git init "$P" &&
1032 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1034 echo my-blob >"$P/my-blob" &&
1035 git -C "$P" add my-blob &&
1036 git -C "$P" commit -m x &&
1038 configure_exclusion "$P" my-blob >h &&
1040 git init http_child &&
1042 GIT_TEST_SIDEBAND_ALL=1 \
1043 git -C http_child -c protocol.version=2 \
1044 -c fetch.uriprotocols=http,https \
1045 fetch "$HTTPD_URL/smart/http_parent"
1048 test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
1049 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1050 rm -rf "$P" http_child log &&
1052 git init "$P" &&
1053 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1055 echo my-blob >"$P/my-blob" &&
1056 git -C "$P" add my-blob &&
1057 echo other-blob >"$P/other-blob" &&
1058 git -C "$P" add other-blob &&
1059 git -C "$P" commit -m x &&
1061 configure_exclusion "$P" my-blob >h &&
1062 # Configure a URL for other-blob. Just reuse the hash of the object as
1063 # the hash of the packfile, since the hash does not matter for this
1064 # test as long as it is not the hash of the pack, and it is of the
1065 # expected length.
1066 git -C "$P" hash-object other-blob >objh &&
1067 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1068 git -C "$P" config --add \
1069 "uploadpack.blobpackfileuri" \
1070 "$(cat objh) $(cat objh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1072 test_must_fail env GIT_TEST_SIDEBAND_ALL=1 \
1073 git -c protocol.version=2 \
1074 -c fetch.uriprotocols=http,https \
1075 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1076 test_i18ngrep "pack downloaded from.*does not match expected hash" err
1079 test_expect_success 'packfile-uri with transfer.fsckobjects' '
1080 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1081 rm -rf "$P" http_child log &&
1083 git init "$P" &&
1084 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1086 echo my-blob >"$P/my-blob" &&
1087 git -C "$P" add my-blob &&
1088 git -C "$P" commit -m x &&
1090 configure_exclusion "$P" my-blob >h &&
1092 sane_unset GIT_TEST_SIDEBAND_ALL &&
1093 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1094 -c fetch.uriprotocols=http,https \
1095 clone "$HTTPD_URL/smart/http_parent" http_child &&
1097 # Ensure that there are exactly 2 packfiles with associated .idx
1098 ls http_child/.git/objects/pack/*.pack \
1099 http_child/.git/objects/pack/*.idx >filelist &&
1100 test_line_count = 4 filelist
1103 test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' '
1104 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1105 rm -rf "$P" http_child log &&
1107 git init "$P" &&
1108 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1110 cat >bogus-commit <<-EOF &&
1111 tree $EMPTY_TREE
1112 author Bugs Bunny 1234567890 +0000
1113 committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
1115 This commit object intentionally broken
1117 BOGUS=$(git -C "$P" hash-object -t commit -w --stdin <bogus-commit) &&
1118 git -C "$P" branch bogus-branch "$BOGUS" &&
1120 echo my-blob >"$P/my-blob" &&
1121 git -C "$P" add my-blob &&
1122 git -C "$P" commit -m x &&
1124 configure_exclusion "$P" my-blob >h &&
1126 sane_unset GIT_TEST_SIDEBAND_ALL &&
1127 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1128 -c fetch.uriprotocols=http,https \
1129 clone "$HTTPD_URL/smart/http_parent" http_child 2>error &&
1130 test_i18ngrep "invalid author/committer line - missing email" error
1133 test_expect_success 'packfile-uri with transfer.fsckobjects succeeds when .gitmodules is separate from tree' '
1134 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1135 rm -rf "$P" http_child &&
1137 git init "$P" &&
1138 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1140 echo "[submodule libfoo]" >"$P/.gitmodules" &&
1141 echo "path = include/foo" >>"$P/.gitmodules" &&
1142 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1143 git -C "$P" add .gitmodules &&
1144 git -C "$P" commit -m x &&
1146 configure_exclusion "$P" .gitmodules >h &&
1148 sane_unset GIT_TEST_SIDEBAND_ALL &&
1149 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1150 -c fetch.uriprotocols=http,https \
1151 clone "$HTTPD_URL/smart/http_parent" http_child &&
1153 # Ensure that there are exactly 2 packfiles with associated .idx
1154 ls http_child/.git/objects/pack/*.pack \
1155 http_child/.git/objects/pack/*.idx >filelist &&
1156 test_line_count = 4 filelist
1159 test_expect_success 'packfile-uri with transfer.fsckobjects fails when .gitmodules separate from tree is invalid' '
1160 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1161 rm -rf "$P" http_child err &&
1163 git init "$P" &&
1164 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1166 echo "[submodule \"..\"]" >"$P/.gitmodules" &&
1167 echo "path = include/foo" >>"$P/.gitmodules" &&
1168 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1169 git -C "$P" add .gitmodules &&
1170 git -C "$P" commit -m x &&
1172 configure_exclusion "$P" .gitmodules >h &&
1174 sane_unset GIT_TEST_SIDEBAND_ALL &&
1175 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1176 -c fetch.uriprotocols=http,https \
1177 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1178 test_i18ngrep "disallowed submodule name" err
1181 test_expect_success 'packfile-uri path redacted in trace' '
1182 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1183 rm -rf "$P" http_child log &&
1185 git init "$P" &&
1186 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1188 echo my-blob >"$P/my-blob" &&
1189 git -C "$P" add my-blob &&
1190 git -C "$P" commit -m x &&
1192 git -C "$P" hash-object my-blob >objh &&
1193 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1194 git -C "$P" config --add \
1195 "uploadpack.blobpackfileuri" \
1196 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1198 GIT_TRACE_PACKET="$(pwd)/log" \
1199 git -c protocol.version=2 \
1200 -c fetch.uriprotocols=http,https \
1201 clone "$HTTPD_URL/smart/http_parent" http_child &&
1203 grep -F "clone< \\1$(cat packh) $HTTPD_URL/<redacted>" log
1206 test_expect_success 'packfile-uri path not redacted in trace when GIT_TRACE_REDACT=0' '
1207 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1208 rm -rf "$P" http_child log &&
1210 git init "$P" &&
1211 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1213 echo my-blob >"$P/my-blob" &&
1214 git -C "$P" add my-blob &&
1215 git -C "$P" commit -m x &&
1217 git -C "$P" hash-object my-blob >objh &&
1218 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1219 git -C "$P" config --add \
1220 "uploadpack.blobpackfileuri" \
1221 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1223 GIT_TRACE_PACKET="$(pwd)/log" \
1224 GIT_TRACE_REDACT=0 \
1225 git -c protocol.version=2 \
1226 -c fetch.uriprotocols=http,https \
1227 clone "$HTTPD_URL/smart/http_parent" http_child &&
1229 grep -F "clone< \\1$(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" log
1232 test_expect_success 'http:// --negotiate-only' '
1233 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1234 URI="$HTTPD_URL/smart/server" &&
1236 setup_negotiate_only "$SERVER" "$URI" &&
1238 git -c protocol.version=2 -C client fetch \
1239 --no-tags \
1240 --negotiate-only \
1241 --negotiation-tip=$(git -C client rev-parse HEAD) \
1242 origin >out &&
1243 COMMON=$(git -C "$SERVER" rev-parse two) &&
1244 grep "$COMMON" out
1247 test_expect_success 'http:// --negotiate-only without wait-for-done support' '
1248 SERVER="server" &&
1249 URI="$HTTPD_URL/one_time_perl/server" &&
1251 setup_negotiate_only "$SERVER" "$URI" &&
1253 echo "s/ wait-for-done/ xxxx-xxx-xxxx/" \
1254 >"$HTTPD_ROOT_PATH/one-time-perl" &&
1256 test_must_fail git -c protocol.version=2 -C client fetch \
1257 --no-tags \
1258 --negotiate-only \
1259 --negotiation-tip=$(git -C client rev-parse HEAD) \
1260 origin 2>err &&
1261 test_i18ngrep "server does not support wait-for-done" err
1264 test_expect_success 'http:// --negotiate-only with protocol v0' '
1265 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1266 URI="$HTTPD_URL/smart/server" &&
1268 setup_negotiate_only "$SERVER" "$URI" &&
1270 test_must_fail git -c protocol.version=0 -C client fetch \
1271 --no-tags \
1272 --negotiate-only \
1273 --negotiation-tip=$(git -C client rev-parse HEAD) \
1274 origin 2>err &&
1275 test_i18ngrep "negotiate-only requires protocol v2" err
1278 # DO NOT add non-httpd-specific tests here, because the last part of this
1279 # test script is only executed when httpd is available and enabled.
1281 test_done