The fourth batch
[git/debian.git] / t / t5702-protocol-v2.sh
blob71aabe30b7d76a5663529fa050a5f99a7e580d73
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_expect_success 'push with custom path does not request v2' '
732 rm -f env.trace &&
733 git -C client push \
734 --receive-pack="env >../env.trace; git-receive-pack" \
735 origin HEAD:refs/heads/custom-push-test &&
736 test_path_is_file env.trace &&
737 ! grep ^GIT_PROTOCOL env.trace
740 test_expect_success 'fetch with custom path does request v2' '
741 rm -f env.trace &&
742 git -C client fetch \
743 --upload-pack="env >../env.trace; git-upload-pack" \
744 origin HEAD &&
745 grep ^GIT_PROTOCOL=version=2 env.trace
748 test_expect_success 'archive with custom path does not request v2' '
749 rm -f env.trace &&
750 git -C client archive \
751 --exec="env >../env.trace; git-upload-archive" \
752 --remote=origin \
753 HEAD >/dev/null &&
754 test_path_is_file env.trace &&
755 ! grep ^GIT_PROTOCOL env.trace
758 # Test protocol v2 with 'http://' transport
760 . "$TEST_DIRECTORY"/lib-httpd.sh
761 start_httpd
763 test_expect_success 'create repo to be served by http:// transport' '
764 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
765 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
766 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
769 test_expect_success 'clone with http:// using protocol v2' '
770 test_when_finished "rm -f log" &&
772 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
773 clone "$HTTPD_URL/smart/http_parent" http_child &&
775 git -C http_child log -1 --format=%s >actual &&
776 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
777 test_cmp expect actual &&
779 # Client requested to use protocol v2
780 grep "Git-Protocol: version=2" log &&
781 # Server responded using protocol v2
782 grep "git< version 2" log &&
783 # Verify that the chunked encoding sending codepath is NOT exercised
784 ! grep "Send header: Transfer-Encoding: chunked" log
787 test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline length' '
788 test_when_finished "rm -f log" &&
790 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" &&
791 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" file &&
793 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
794 clone "$HTTPD_URL/smart/incomplete_length" incomplete_length_child 2>err &&
796 # Client requested to use protocol v2
797 grep "Git-Protocol: version=2" log &&
798 # Server responded using protocol v2
799 grep "git< version 2" log &&
800 # Client reported appropriate failure
801 test_i18ngrep "bytes of length header were received" err
804 test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline body' '
805 test_when_finished "rm -f log" &&
807 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" &&
808 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" file &&
810 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
811 clone "$HTTPD_URL/smart/incomplete_body" incomplete_body_child 2>err &&
813 # Client requested to use protocol v2
814 grep "Git-Protocol: version=2" log &&
815 # Server responded using protocol v2
816 grep "git< version 2" log &&
817 # Client reported appropriate failure
818 test_i18ngrep "bytes of body are still expected" err
821 test_expect_success 'clone with http:// using protocol v2 and invalid parameters' '
822 test_when_finished "rm -f log" &&
824 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" \
825 git -c protocol.version=2 \
826 clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid &&
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
834 test_expect_success 'clone big repository with http:// using protocol v2' '
835 test_when_finished "rm -f log" &&
837 git init "$HTTPD_DOCUMENT_ROOT_PATH/big" &&
838 # Ensure that the list of wants is greater than http.postbuffer below
839 for i in $(test_seq 1 1500)
841 # do not use here-doc, because it requires a process
842 # per loop iteration
843 echo "commit refs/heads/too-many-refs-$i" &&
844 echo "committer git <git@example.com> $i +0000" &&
845 echo "data 0" &&
846 echo "M 644 inline bla.txt" &&
847 echo "data 4" &&
848 echo "bla" || return 1
849 done | git -C "$HTTPD_DOCUMENT_ROOT_PATH/big" fast-import &&
851 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git \
852 -c protocol.version=2 -c http.postbuffer=65536 \
853 clone "$HTTPD_URL/smart/big" big_child &&
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 # Verify that the chunked encoding sending codepath is exercised
860 grep "Send header: Transfer-Encoding: chunked" log
863 test_expect_success 'fetch with http:// using protocol v2' '
864 test_when_finished "rm -f log" &&
866 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
868 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
869 fetch &&
871 git -C http_child log -1 --format=%s origin/main >actual &&
872 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
873 test_cmp expect actual &&
875 # Server responded using protocol v2
876 grep "git< version 2" log
879 test_expect_success 'fetch with http:// by hash without tag following with protocol v2 does not list refs' '
880 test_when_finished "rm -f log" &&
882 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two_a &&
883 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" rev-parse two_a >two_a_hash &&
885 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
886 fetch --no-tags origin $(cat two_a_hash) &&
888 grep "fetch< version 2" log &&
889 ! grep "fetch> command=ls-refs" log
892 test_expect_success 'fetch from namespaced repo respects namespaces' '
893 test_when_finished "rm -f log" &&
895 git init "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" &&
896 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one &&
897 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two &&
898 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \
899 update-ref refs/namespaces/ns/refs/heads/main one &&
901 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
902 fetch "$HTTPD_URL/smart_namespace/nsrepo" \
903 refs/heads/main:refs/heads/theirs &&
905 # Server responded using protocol v2
906 grep "fetch< version 2" log &&
908 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect &&
909 git -C http_child rev-parse theirs >actual &&
910 test_cmp expect actual
913 test_expect_success 'ls-remote with v2 http sends only one POST' '
914 test_when_finished "rm -f log" &&
916 git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
917 GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
918 ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
919 test_cmp expect actual &&
921 grep "Send header: POST" log >posts &&
922 test_line_count = 1 posts
925 test_expect_success 'push with http:// and a config of v2 does not request v2' '
926 test_when_finished "rm -f log" &&
927 # Till v2 for push is designed, make sure that if a client has
928 # protocol.version configured to use v2, that the client instead falls
929 # back and uses v0.
931 test_commit -C http_child three &&
933 # Push to another branch, as the target repository has the
934 # main branch checked out and we cannot push into it.
935 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
936 push origin HEAD:client_branch &&
938 git -C http_child log -1 --format=%s >actual &&
939 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
940 test_cmp expect actual &&
942 # Client did not request to use protocol v2
943 ! grep "Git-Protocol: version=2" log &&
944 # Server did not respond using protocol v2
945 ! grep "git< version 2" log
948 test_expect_success 'when server sends "ready", expect DELIM' '
949 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child &&
951 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
952 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
954 git clone "$HTTPD_URL/smart/http_parent" http_child &&
956 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
958 # After "ready" in the acknowledgments section, pretend that a FLUSH
959 # (0000) was sent instead of a DELIM (0001).
960 printf "\$ready = 1 if /ready/; \$ready && s/0001/0000/" \
961 >"$HTTPD_ROOT_PATH/one-time-perl" &&
963 test_must_fail git -C http_child -c protocol.version=2 \
964 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
965 test_i18ngrep "expected packfile to be sent after .ready." err
968 test_expect_success 'when server does not send "ready", expect FLUSH' '
969 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log &&
971 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
972 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
974 git clone "$HTTPD_URL/smart/http_parent" http_child &&
976 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
978 # Create many commits to extend the negotiation phase across multiple
979 # requests, so that the server does not send "ready" in the first
980 # request.
981 test_commit_bulk -C http_child --id=c 32 &&
983 # After the acknowledgments section, pretend that a DELIM
984 # (0001) was sent instead of a FLUSH (0000).
985 printf "\$ack = 1 if /acknowledgments/; \$ack && s/0000/0001/" \
986 >"$HTTPD_ROOT_PATH/one-time-perl" &&
988 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
989 -c protocol.version=2 \
990 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
991 grep "fetch< .*acknowledgments" log &&
992 ! grep "fetch< .*ready" log &&
993 test_i18ngrep "expected no other sections to be sent after no .ready." err
996 configure_exclusion () {
997 git -C "$1" hash-object "$2" >objh &&
998 git -C "$1" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
999 git -C "$1" config --add \
1000 "uploadpack.blobpackfileuri" \
1001 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1002 cat objh
1005 test_expect_success 'part of packfile response provided as URI' '
1006 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1007 rm -rf "$P" http_child log &&
1009 git init "$P" &&
1010 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1012 echo my-blob >"$P/my-blob" &&
1013 git -C "$P" add my-blob &&
1014 echo other-blob >"$P/other-blob" &&
1015 git -C "$P" add other-blob &&
1016 git -C "$P" commit -m x &&
1018 configure_exclusion "$P" my-blob >h &&
1019 configure_exclusion "$P" other-blob >h2 &&
1021 GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
1022 git -c protocol.version=2 \
1023 -c fetch.uriprotocols=http,https \
1024 clone "$HTTPD_URL/smart/http_parent" http_child &&
1026 # Ensure that my-blob and other-blob are in separate packfiles.
1027 for idx in http_child/.git/objects/pack/*.idx
1029 git verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&
1031 grep -E "^[0-9a-f]{16,} " out || :
1032 } >out.objectlist &&
1033 if test_line_count = 1 out.objectlist
1034 then
1035 if grep $(cat h) out
1036 then
1037 >hfound
1038 fi &&
1039 if grep $(cat h2) out
1040 then
1041 >h2found
1043 fi || return 1
1044 done &&
1045 test -f hfound &&
1046 test -f h2found &&
1048 # Ensure that there are exactly 3 packfiles with associated .idx
1049 ls http_child/.git/objects/pack/*.pack \
1050 http_child/.git/objects/pack/*.idx >filelist &&
1051 test_line_count = 6 filelist
1054 test_expect_success 'packfile URIs with fetch instead of clone' '
1055 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1056 rm -rf "$P" http_child log &&
1058 git init "$P" &&
1059 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1061 echo my-blob >"$P/my-blob" &&
1062 git -C "$P" add my-blob &&
1063 git -C "$P" commit -m x &&
1065 configure_exclusion "$P" my-blob >h &&
1067 git init http_child &&
1069 GIT_TEST_SIDEBAND_ALL=1 \
1070 git -C http_child -c protocol.version=2 \
1071 -c fetch.uriprotocols=http,https \
1072 fetch "$HTTPD_URL/smart/http_parent"
1075 test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
1076 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1077 rm -rf "$P" http_child log &&
1079 git init "$P" &&
1080 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1082 echo my-blob >"$P/my-blob" &&
1083 git -C "$P" add my-blob &&
1084 echo other-blob >"$P/other-blob" &&
1085 git -C "$P" add other-blob &&
1086 git -C "$P" commit -m x &&
1088 configure_exclusion "$P" my-blob >h &&
1089 # Configure a URL for other-blob. Just reuse the hash of the object as
1090 # the hash of the packfile, since the hash does not matter for this
1091 # test as long as it is not the hash of the pack, and it is of the
1092 # expected length.
1093 git -C "$P" hash-object other-blob >objh &&
1094 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1095 git -C "$P" config --add \
1096 "uploadpack.blobpackfileuri" \
1097 "$(cat objh) $(cat objh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1099 test_must_fail env GIT_TEST_SIDEBAND_ALL=1 \
1100 git -c protocol.version=2 \
1101 -c fetch.uriprotocols=http,https \
1102 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1103 test_i18ngrep "pack downloaded from.*does not match expected hash" err
1106 test_expect_success 'packfile-uri with transfer.fsckobjects' '
1107 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1108 rm -rf "$P" http_child log &&
1110 git init "$P" &&
1111 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1113 echo my-blob >"$P/my-blob" &&
1114 git -C "$P" add my-blob &&
1115 git -C "$P" commit -m x &&
1117 configure_exclusion "$P" my-blob >h &&
1119 sane_unset GIT_TEST_SIDEBAND_ALL &&
1120 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1121 -c fetch.uriprotocols=http,https \
1122 clone "$HTTPD_URL/smart/http_parent" http_child &&
1124 # Ensure that there are exactly 2 packfiles with associated .idx
1125 ls http_child/.git/objects/pack/*.pack \
1126 http_child/.git/objects/pack/*.idx >filelist &&
1127 test_line_count = 4 filelist
1130 test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' '
1131 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1132 rm -rf "$P" http_child log &&
1134 git init "$P" &&
1135 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1137 cat >bogus-commit <<-EOF &&
1138 tree $EMPTY_TREE
1139 author Bugs Bunny 1234567890 +0000
1140 committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
1142 This commit object intentionally broken
1144 BOGUS=$(git -C "$P" hash-object -t commit -w --stdin --literally <bogus-commit) &&
1145 git -C "$P" branch bogus-branch "$BOGUS" &&
1147 echo my-blob >"$P/my-blob" &&
1148 git -C "$P" add my-blob &&
1149 git -C "$P" commit -m x &&
1151 configure_exclusion "$P" my-blob >h &&
1153 sane_unset GIT_TEST_SIDEBAND_ALL &&
1154 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1155 -c fetch.uriprotocols=http,https \
1156 clone "$HTTPD_URL/smart/http_parent" http_child 2>error &&
1157 test_i18ngrep "invalid author/committer line - missing email" error
1160 test_expect_success 'packfile-uri with transfer.fsckobjects succeeds when .gitmodules is separate from tree' '
1161 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1162 rm -rf "$P" http_child &&
1164 git init "$P" &&
1165 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1167 echo "[submodule libfoo]" >"$P/.gitmodules" &&
1168 echo "path = include/foo" >>"$P/.gitmodules" &&
1169 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1170 git -C "$P" add .gitmodules &&
1171 git -C "$P" commit -m x &&
1173 configure_exclusion "$P" .gitmodules >h &&
1175 sane_unset GIT_TEST_SIDEBAND_ALL &&
1176 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1177 -c fetch.uriprotocols=http,https \
1178 clone "$HTTPD_URL/smart/http_parent" http_child &&
1180 # Ensure that there are exactly 2 packfiles with associated .idx
1181 ls http_child/.git/objects/pack/*.pack \
1182 http_child/.git/objects/pack/*.idx >filelist &&
1183 test_line_count = 4 filelist
1186 test_expect_success 'packfile-uri with transfer.fsckobjects fails when .gitmodules separate from tree is invalid' '
1187 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1188 rm -rf "$P" http_child err &&
1190 git init "$P" &&
1191 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1193 echo "[submodule \"..\"]" >"$P/.gitmodules" &&
1194 echo "path = include/foo" >>"$P/.gitmodules" &&
1195 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1196 git -C "$P" add .gitmodules &&
1197 git -C "$P" commit -m x &&
1199 configure_exclusion "$P" .gitmodules >h &&
1201 sane_unset GIT_TEST_SIDEBAND_ALL &&
1202 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1203 -c fetch.uriprotocols=http,https \
1204 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1205 test_i18ngrep "disallowed submodule name" err
1208 test_expect_success 'packfile-uri path redacted in trace' '
1209 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1210 rm -rf "$P" http_child log &&
1212 git init "$P" &&
1213 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1215 echo my-blob >"$P/my-blob" &&
1216 git -C "$P" add my-blob &&
1217 git -C "$P" commit -m x &&
1219 git -C "$P" hash-object my-blob >objh &&
1220 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1221 git -C "$P" config --add \
1222 "uploadpack.blobpackfileuri" \
1223 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1225 GIT_TRACE_PACKET="$(pwd)/log" \
1226 git -c protocol.version=2 \
1227 -c fetch.uriprotocols=http,https \
1228 clone "$HTTPD_URL/smart/http_parent" http_child &&
1230 grep -F "clone< \\1$(cat packh) $HTTPD_URL/<redacted>" log
1233 test_expect_success 'packfile-uri path not redacted in trace when GIT_TRACE_REDACT=0' '
1234 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1235 rm -rf "$P" http_child log &&
1237 git init "$P" &&
1238 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1240 echo my-blob >"$P/my-blob" &&
1241 git -C "$P" add my-blob &&
1242 git -C "$P" commit -m x &&
1244 git -C "$P" hash-object my-blob >objh &&
1245 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
1246 git -C "$P" config --add \
1247 "uploadpack.blobpackfileuri" \
1248 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
1250 GIT_TRACE_PACKET="$(pwd)/log" \
1251 GIT_TRACE_REDACT=0 \
1252 git -c protocol.version=2 \
1253 -c fetch.uriprotocols=http,https \
1254 clone "$HTTPD_URL/smart/http_parent" http_child &&
1256 grep -F "clone< \\1$(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" log
1259 test_expect_success 'http:// --negotiate-only' '
1260 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1261 URI="$HTTPD_URL/smart/server" &&
1263 setup_negotiate_only "$SERVER" "$URI" &&
1265 git -c protocol.version=2 -C client fetch \
1266 --no-tags \
1267 --negotiate-only \
1268 --negotiation-tip=$(git -C client rev-parse HEAD) \
1269 origin >out &&
1270 COMMON=$(git -C "$SERVER" rev-parse two) &&
1271 grep "$COMMON" out
1274 test_expect_success 'http:// --negotiate-only without wait-for-done support' '
1275 SERVER="server" &&
1276 URI="$HTTPD_URL/one_time_perl/server" &&
1278 setup_negotiate_only "$SERVER" "$URI" &&
1280 echo "s/ wait-for-done/ xxxx-xxx-xxxx/" \
1281 >"$HTTPD_ROOT_PATH/one-time-perl" &&
1283 test_must_fail git -c protocol.version=2 -C client fetch \
1284 --no-tags \
1285 --negotiate-only \
1286 --negotiation-tip=$(git -C client rev-parse HEAD) \
1287 origin 2>err &&
1288 test_i18ngrep "server does not support wait-for-done" err
1291 test_expect_success 'http:// --negotiate-only with protocol v0' '
1292 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1293 URI="$HTTPD_URL/smart/server" &&
1295 setup_negotiate_only "$SERVER" "$URI" &&
1297 test_must_fail git -c protocol.version=0 -C client fetch \
1298 --no-tags \
1299 --negotiate-only \
1300 --negotiation-tip=$(git -C client rev-parse HEAD) \
1301 origin 2>err &&
1302 test_i18ngrep "negotiate-only requires protocol v2" err
1305 # DO NOT add non-httpd-specific tests here, because the last part of this
1306 # test script is only executed when httpd is available and enabled.
1308 test_done