5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 test_have_prereq
!MINGW || X
=.exe
13 test_expect_success setup
'
16 test_create_repo src &&
21 git commit -m initial &&
29 test_expect_success
'clone with excess parameters (1)' '
32 test_must_fail git clone -n src dst junk
36 test_expect_success
'clone with excess parameters (2)' '
39 test_must_fail git clone -n "file://$(pwd)/src" dst junk
43 test_expect_success
'output from clone' '
45 git clone -n "file://$(pwd)/src" dst >output 2>&1 &&
46 test $(grep Clon output | wc -l) = 1
49 test_expect_success
'output from clone with core.abbrev does not crash' '
51 echo "Cloning into ${SQ}dst${SQ}..." >expect &&
52 git -c core.abbrev=12 clone -n "file://$(pwd)/src" dst >actual 2>&1 &&
53 test_cmp expect actual
56 test_expect_success
'clone does not keep pack' '
59 git clone -n "file://$(pwd)/src" dst &&
61 ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
65 test_expect_success
'clone checks out files' '
73 test_expect_success
'clone respects GIT_WORK_TREE' '
75 GIT_WORK_TREE=worktree git clone src bare &&
76 test -f bare/config &&
81 test_expect_success
'clone from hooks' '
83 test_create_repo r0 &&
85 test_commit initial &&
89 test_hook pre-commit <<-\EOF &&
95 test_must_fail git commit -m invoke-hook &&
97 test_cmp r0/.git/HEAD r2/.git/HEAD &&
98 test_cmp r0/initial.t r2/initial.t
102 test_expect_success
'clone creates intermediate directories' '
104 git clone src long/path/to/dst &&
105 test -f long/path/to/dst/file
109 test_expect_success
'clone creates intermediate directories for bare repo' '
111 git clone --bare src long/path/to/bare/dst &&
112 test -f long/path/to/bare/dst/config
116 test_expect_success
'clone --mirror' '
118 git clone --mirror src mirror &&
119 test -f mirror/HEAD &&
120 test ! -f mirror/file &&
121 FETCH="$(cd mirror && git config remote.origin.fetch)" &&
122 test "+refs/*:refs/*" = "$FETCH" &&
123 MIRROR="$(cd mirror && git config --bool remote.origin.mirror)" &&
124 test "$MIRROR" = true
128 test_expect_success
'clone --mirror with detached HEAD' '
130 ( cd src && git checkout HEAD^ && git rev-parse HEAD >../expected ) &&
131 git clone --mirror src mirror.detached &&
132 ( cd src && git checkout - ) &&
133 GIT_DIR=mirror.detached git rev-parse HEAD >actual &&
134 test_cmp expected actual
138 test_expect_success
'clone --bare with detached HEAD' '
140 ( cd src && git checkout HEAD^ && git rev-parse HEAD >../expected ) &&
141 git clone --bare src bare.detached &&
142 ( cd src && git checkout - ) &&
143 GIT_DIR=bare.detached git rev-parse HEAD >actual &&
144 test_cmp expected actual
148 test_expect_success
'clone --bare names the local repository <name>.git' '
150 git clone --bare src &&
155 test_expect_success
'clone --mirror does not repeat tags' '
158 git tag some-tag HEAD) &&
159 git clone --mirror src mirror2 &&
161 git show-ref 2> clone.err > clone.out) &&
162 ! grep Duplicate mirror2/clone.err &&
163 grep some-tag mirror2/clone.out
167 test_expect_success
'clone with files ref format' '
168 test_when_finished "rm -rf ref-storage" &&
169 git clone --ref-format=files --mirror src ref-storage &&
170 echo files >expect &&
171 git -C ref-storage rev-parse --show-ref-format >actual &&
172 test_cmp expect actual
175 test_expect_success
'clone with garbage ref format' '
176 cat >expect <<-EOF &&
177 fatal: unknown ref storage format ${SQ}garbage${SQ}
179 test_must_fail git clone --ref-format=garbage --mirror src ref-storage 2>err &&
180 test_cmp expect err &&
181 test_path_is_missing ref-storage
184 test_expect_success
'clone to destination with trailing /' '
186 git clone src target-1/ &&
187 T=$( cd target-1 && git rev-parse HEAD ) &&
188 S=$( cd src && git rev-parse HEAD ) &&
193 test_expect_success
'clone to destination with extra trailing /' '
195 git clone src target-2/// &&
196 T=$( cd target-2 && git rev-parse HEAD ) &&
197 S=$( cd src && git rev-parse HEAD ) &&
202 test_expect_success
'clone to an existing empty directory' '
204 git clone src target-3 &&
205 T=$( cd target-3 && git rev-parse HEAD ) &&
206 S=$( cd src && git rev-parse HEAD ) &&
210 test_expect_success
'clone to an existing non-empty directory' '
212 >target-4/Fakefile &&
213 test_must_fail git clone src target-4
216 test_expect_success
'clone to an existing path' '
218 test_must_fail git clone src target-5
221 test_expect_success
'clone a void' '
226 git clone "file://$(pwd)/src-0" target-6 2>err-6 &&
227 ! grep "fatal:" err-6 &&
229 cd src-0 && test_commit A
231 git clone "file://$(pwd)/src-0" target-7 2>err-7 &&
232 ! grep "fatal:" err-7 &&
233 # There is no reason to insist they are bit-for-bit
234 # identical, but this test should suffice for now.
235 test_cmp target-6/.git/config target-7/.git/config
238 test_expect_success
'clone respects global branch.autosetuprebase' '
240 test_config="$HOME/.gitconfig" &&
241 git config -f "$test_config" branch.autosetuprebase remote &&
245 actual="z$(git config branch.main.rebase)" &&
250 test_expect_success
'respect url-encoding of file://' '
252 git clone "file://$PWD/x+y" xy-url-1 &&
253 git clone "file://$PWD/x%2By" xy-url-2
256 test_expect_success
'do not query-string-decode + in URLs' '
259 test_must_fail git clone "file://$PWD/x+y" xy-no-plus
262 test_expect_success
'do not respect url-encoding of non-url path' '
264 test_must_fail git clone x%2By xy-regular &&
265 git clone x+y xy-regular
268 test_expect_success
'clone separate gitdir' '
270 git clone --separate-git-dir realgitdir src dst &&
271 test -d realgitdir/refs
274 test_expect_success
'clone separate gitdir: output' '
275 echo "gitdir: $(pwd)/realgitdir" >expected &&
276 test_cmp expected dst/.git
279 test_expect_success
'clone from .git file' '
280 git clone dst/.git dst2
283 test_expect_success
'fetch from .git gitfile' '
286 git fetch ../dst/.git
290 test_expect_success
'fetch from gitfile parent' '
297 test_expect_success
'clone separate gitdir where target already exists' '
299 echo foo=bar >>realgitdir/config &&
300 test_must_fail git clone --separate-git-dir realgitdir src dst &&
301 grep foo=bar realgitdir/config
304 test_expect_success
'clone --reference from original' '
305 git clone --shared --bare src src-1 &&
306 git clone --bare src src-2 &&
307 git clone --reference=src-2 --bare src-1 target-8 &&
308 grep /src-2/ target-8/objects/info/alternates
311 test_expect_success
'clone with more than one --reference' '
312 git clone --bare src src-3 &&
313 git clone --bare src src-4 &&
314 git clone --reference=src-3 --reference=src-4 src target-9 &&
315 grep /src-3/ target-9/.git/objects/info/alternates &&
316 grep /src-4/ target-9/.git/objects/info/alternates
319 test_expect_success
'clone from original with relative alternate' '
321 git clone --bare src nest/src-5 &&
322 echo ../../../src/.git/objects >nest/src-5/objects/info/alternates &&
323 git clone --bare nest/src-5 target-10 &&
324 grep /src/\\.git/objects target-10/objects/info/alternates
327 test_expect_success
'clone checking out a tag' '
328 git clone --branch=some-tag src dst.tag &&
329 GIT_DIR=src/.git git rev-parse some-tag >expected &&
330 GIT_DIR=dst.tag/.git git rev-parse HEAD >actual &&
331 test_cmp expected actual &&
332 GIT_DIR=dst.tag/.git git config remote.origin.fetch >fetch.actual &&
333 echo "+refs/heads/*:refs/remotes/origin/*" >fetch.expected &&
334 test_cmp fetch.expected fetch.actual
337 test_expect_success
'set up ssh wrapper' '
338 cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" \
339 "$TRASH_DIRECTORY/ssh$X" &&
340 GIT_SSH="$TRASH_DIRECTORY/ssh$X" &&
342 export TRASH_DIRECTORY &&
343 >"$TRASH_DIRECTORY"/ssh-output
346 copy_ssh_wrapper_as
() {
348 cp "$TRASH_DIRECTORY/ssh$X" "${1%$X}$X" &&
349 test_when_finished
"rm $(git rev-parse --sq-quote "${1%$X}$X")" &&
350 GIT_SSH
="${1%$X}$X" &&
351 test_when_finished
"GIT_SSH=\"\$TRASH_DIRECTORY/ssh\$X\""
356 (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
363 echo "ssh: $1 git-upload-pack '$2'"
366 echo "ssh: $1 $2 git-upload-pack '$3'"
369 echo "ssh: $1 $2 git-upload-pack '$3' $4"
371 } >"$TRASH_DIRECTORY/ssh-expect" &&
372 (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output
)
375 test_expect_success
'clone myhost:src uses ssh' '
376 GIT_TEST_PROTOCOL_VERSION=0 git clone myhost:src ssh-clone &&
377 expect_ssh myhost src
380 test_expect_success
!MINGW
,!CYGWIN
'clone local path foo:bar' '
381 cp -R src "foo:bar" &&
382 git clone "foo:bar" foobar &&
386 test_expect_success
'bracketed hostnames are still ssh' '
387 GIT_TEST_PROTOCOL_VERSION=0 git clone "[myhost:123]:src" ssh-bracket-clone &&
388 expect_ssh "-p 123" myhost src
391 test_expect_success
'OpenSSH variant passes -4' '
392 GIT_TEST_PROTOCOL_VERSION=0 git clone -4 "[myhost:123]:src" ssh-ipv4-clone &&
393 expect_ssh "-4 -p 123" myhost src
396 test_expect_success
'variant can be overridden' '
397 copy_ssh_wrapper_as "$TRASH_DIRECTORY/putty" &&
398 git -c ssh.variant=putty clone -4 "[myhost:123]:src" ssh-putty-clone &&
399 expect_ssh "-4 -P 123" myhost src
402 test_expect_success
'variant=auto picks based on basename' '
403 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
404 git -c ssh.variant=auto clone -4 "[myhost:123]:src" ssh-auto-clone &&
405 expect_ssh "-4 -P 123" myhost src
408 test_expect_success
'simple does not support -4/-6' '
409 copy_ssh_wrapper_as "$TRASH_DIRECTORY/simple" &&
410 test_must_fail git clone -4 "myhost:src" ssh-4-clone-simple
413 test_expect_success
'simple does not support port' '
414 copy_ssh_wrapper_as "$TRASH_DIRECTORY/simple" &&
415 test_must_fail git clone "[myhost:123]:src" ssh-bracket-clone-simple
418 test_expect_success
'uplink is treated as simple' '
419 copy_ssh_wrapper_as "$TRASH_DIRECTORY/uplink" &&
420 test_must_fail git clone "[myhost:123]:src" ssh-bracket-clone-uplink &&
421 git clone "myhost:src" ssh-clone-uplink &&
422 expect_ssh myhost src
425 test_expect_success
'OpenSSH-like uplink is treated as ssh' '
426 write_script "$TRASH_DIRECTORY/uplink" <<-EOF &&
431 exec "\$TRASH_DIRECTORY/ssh$X" "\$@"
433 test_when_finished "rm -f \"\$TRASH_DIRECTORY/uplink\"" &&
434 GIT_SSH="$TRASH_DIRECTORY/uplink" &&
435 test_when_finished "GIT_SSH=\"\$TRASH_DIRECTORY/ssh\$X\"" &&
436 GIT_TEST_PROTOCOL_VERSION=0 git clone "[myhost:123]:src" ssh-bracket-clone-sshlike-uplink &&
437 expect_ssh "-p 123" myhost src
440 test_expect_success
'plink is treated specially (as putty)' '
441 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
442 git clone "[myhost:123]:src" ssh-bracket-clone-plink-0 &&
443 expect_ssh "-P 123" myhost src
446 test_expect_success
'plink.exe is treated specially (as putty)' '
447 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" &&
448 git clone "[myhost:123]:src" ssh-bracket-clone-plink-1 &&
449 expect_ssh "-P 123" myhost src
452 test_expect_success
'tortoiseplink is like putty, with extra arguments' '
453 copy_ssh_wrapper_as "$TRASH_DIRECTORY/tortoiseplink" &&
454 git clone "[myhost:123]:src" ssh-bracket-clone-plink-2 &&
455 expect_ssh "-batch -P 123" myhost src
458 test_expect_success
'double quoted plink.exe in GIT_SSH_COMMAND' '
459 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" &&
460 GIT_SSH_COMMAND="\"$TRASH_DIRECTORY/plink.exe\" -v" \
461 git clone "[myhost:123]:src" ssh-bracket-clone-plink-3 &&
462 expect_ssh "-v -P 123" myhost src
465 test_expect_success
'single quoted plink.exe in GIT_SSH_COMMAND' '
466 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" &&
467 GIT_SSH_COMMAND="$SQ$TRASH_DIRECTORY/plink.exe$SQ -v" \
468 git clone "[myhost:123]:src" ssh-bracket-clone-plink-4 &&
469 expect_ssh "-v -P 123" myhost src
472 test_expect_success
'GIT_SSH_VARIANT overrides plink detection' '
473 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
474 GIT_TEST_PROTOCOL_VERSION=0 GIT_SSH_VARIANT=ssh \
475 git clone "[myhost:123]:src" ssh-bracket-clone-variant-1 &&
476 expect_ssh "-p 123" myhost src
479 test_expect_success
'ssh.variant overrides plink detection' '
480 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
481 GIT_TEST_PROTOCOL_VERSION=0 git -c ssh.variant=ssh \
482 clone "[myhost:123]:src" ssh-bracket-clone-variant-2 &&
483 expect_ssh "-p 123" myhost src
486 test_expect_success
'GIT_SSH_VARIANT overrides plink detection to plink' '
487 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
488 GIT_SSH_VARIANT=plink \
489 git clone "[myhost:123]:src" ssh-bracket-clone-variant-3 &&
490 expect_ssh "-P 123" myhost src
493 test_expect_success
'GIT_SSH_VARIANT overrides plink to tortoiseplink' '
494 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
495 GIT_SSH_VARIANT=tortoiseplink \
496 git clone "[myhost:123]:src" ssh-bracket-clone-variant-4 &&
497 expect_ssh "-batch -P 123" myhost src
500 test_expect_success
'clean failure on broken quoting' '
502 env GIT_SSH_COMMAND="${SQ}plink.exe -v" \
503 git clone "[myhost:123]:src" sq-failure
511 counter
=$
(($counter + 1))
512 test_might_fail env GIT_TEST_PROTOCOL_VERSION
=0 git clone
"$1" tmp
$counter &&
517 test_expect_success
!MINGW
,!CYGWIN
'clone c:temp is ssl' '
518 test_clone_url c:temp c temp
521 test_expect_success MINGW
'clone c:temp is dos drive' '
522 test_clone_url c:temp none
526 for repo
in rep rep
/home
/project
123
528 test_expect_success
"clone host:$repo" '
529 test_clone_url host:$repo host $repo
533 # Parsing of paths that look like IPv6 addresses is broken on Cygwin.
534 expectation_for_ipv6_tests
=success
535 if test_have_prereq CYGWIN
537 expectation_for_ipv6_tests
=failure
541 for repo
in rep rep
/home
/project
123
543 test_expect_
$expectation_for_ipv6_tests "clone [::1]:$repo" '
544 test_clone_url [::1]:$repo ::1 "$repo"
548 # Home directory. All tests that use "~repo" are broken in our CI job when the
549 # leak sanitizer is enabled. It seems like either a bug in the sanitizer or in
550 # glibc, but when executing getpwnam(3p) with an invalid username we eventually
551 # start recursing in a call to free(3p), until bust the stack and segfault.
552 test_expect_success
!SANITIZE_LEAK
"clone host:/~repo" '
553 test_clone_url host:/~repo host "~repo"
556 test_expect_
$expectation_for_ipv6_tests !SANITIZE_LEAK
"clone [::1]:/~repo" '
557 test_clone_url [::1]:/~repo ::1 "~repo"
561 for url
in foo
/bar
:baz
[foo
]bar
/baz
:qux
[foo
/bar
]:baz
563 test_expect_success
"clone $url is not ssh" '
564 test_clone_url $url none
569 #ignore trailing colon
572 test_expect_success
"clone ssh://host.xz$tcol/home/user/repo" '
573 test_clone_url "ssh://host.xz$tcol/home/user/repo" host.xz /home/user/repo
575 # from home directory
576 test_expect_success
!SANITIZE_LEAK
"clone ssh://host.xz$tcol/~repo" '
577 test_clone_url "ssh://host.xz$tcol/~repo" host.xz "~repo"
582 test_expect_success
'clone ssh://host.xz:22/home/user/repo' '
583 test_clone_url "ssh://host.xz:22/home/user/repo" "-p 22 host.xz" "/home/user/repo"
586 # from home directory with port number
587 test_expect_success
!SANITIZE_LEAK
'clone ssh://host.xz:22/~repo' '
588 test_clone_url "ssh://host.xz:22/~repo" "-p 22 host.xz" "~repo"
592 for tuah
in ::1 [::1] [::1]: user@
::1 user@
[::1] user@
[::1]: [user@
::1] [user@
::1]:
594 ehost
=$
(echo $tuah |
sed -e "s/1]:/1]/" |
tr -d "[]")
595 test_expect_success
"clone ssh://$tuah/home/user/repo" "
596 test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
600 #IPv6 from home directory
601 for tuah
in ::1 [::1] user@
::1 user@
[::1] [user@
::1]
603 euah
=$
(echo $tuah |
tr -d "[]")
604 test_expect_success
!SANITIZE_LEAK
"clone ssh://$tuah/~repo" "
605 test_clone_url ssh://$tuah/~repo $euah '~repo'
609 #IPv6 with port number
610 for tuah
in [::1] user@
[::1] [user@
::1]
612 euah
=$
(echo $tuah |
tr -d "[]")
613 test_expect_success
"clone ssh://$tuah:22/home/user/repo" "
614 test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
618 #IPv6 from home directory with port number
619 for tuah
in [::1] user@
[::1] [user@
::1]
621 euah
=$
(echo $tuah |
tr -d "[]")
622 test_expect_success
!SANITIZE_LEAK
"clone ssh://$tuah:22/~repo" "
623 test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
627 test_expect_success
'clone from a repository with two identical branches' '
631 git checkout -b another main
633 git clone src target-11 &&
634 test "z$( cd target-11 && git symbolic-ref HEAD )" = zrefs/heads/another
638 test_expect_success
'shallow clone locally' '
639 git clone --depth=1 --no-local src ssrrcc &&
640 git clone ssrrcc ddsstt &&
641 test_cmp ssrrcc/.git/shallow ddsstt/.git/shallow &&
642 ( cd ddsstt && git fsck )
645 test_expect_success
'GIT_TRACE_PACKFILE produces a usable pack' '
647 GIT_TRACE_PACKFILE=$PWD/tmp.pack git clone --no-local --bare src dst.git &&
648 git init --bare replay.git &&
649 git -C replay.git index-pack -v --stdin <tmp.pack
652 test_expect_success PERL_TEST_HELPERS
'clone on case-insensitive fs' '
656 o=$(git hash-object -w --stdin </dev/null | hex2oct) &&
657 t=$(printf "100644 X\0${o}100644 x\0${o}" |
658 git hash-object -w -t tree --stdin) &&
659 c=$(git commit-tree -m bogus $t) &&
660 git update-ref refs/heads/bogus $c &&
661 git clone -b bogus . bogus 2>warning
665 test_expect_success PERL_TEST_HELPERS
,CASE_INSENSITIVE_FS
'colliding file detection' '
666 grep X icasefs/warning &&
667 grep x icasefs/warning &&
668 test_grep "the following paths have collided" icasefs/warning
671 test_expect_success CASE_INSENSITIVE_FS
,SYMLINKS \
672 'colliding symlink/directory keeps directory' '
673 git init icasefs-colliding-symlink &&
675 cd icasefs-colliding-symlink &&
676 a=$(printf a | git hash-object -w --stdin) &&
677 printf "100644 %s 0\tA/dir/b\n120000 %s 0\ta\n" $a $a >idx &&
678 git update-index --index-info <idx &&
680 git commit -m initial
682 git clone icasefs-colliding-symlink icasefs-colliding-symlink-clone &&
683 test_file_not_empty icasefs-colliding-symlink-clone/A/dir/b
686 test_expect_success
'clone with GIT_DEFAULT_HASH' '
688 sane_unset GIT_DEFAULT_HASH &&
689 git init --object-format=sha1 test-sha1 &&
690 git init --object-format=sha256 test-sha256
692 test_commit -C test-sha1 foo &&
693 test_commit -C test-sha256 foo &&
694 GIT_DEFAULT_HASH=sha1 git clone test-sha256 test-clone-sha256 &&
695 GIT_DEFAULT_HASH=sha256 git clone test-sha1 test-clone-sha1 &&
696 git -C test-clone-sha1 status &&
697 git -C test-clone-sha256 status
700 partial_clone_server
() {
703 rm -rf "$SERVER" client
&&
704 test_create_repo
"$SERVER" &&
705 test_commit
-C "$SERVER" one
&&
706 HASH1
=$
(git
-C "$SERVER" hash-object one.t
) &&
707 git
-C "$SERVER" revert HEAD
&&
708 test_commit
-C "$SERVER" two
&&
709 HASH2
=$
(git
-C "$SERVER" hash-object two.t
) &&
710 test_config
-C "$SERVER" uploadpack.allowfilter
1 &&
711 test_config
-C "$SERVER" uploadpack.allowanysha1inwant
1
718 partial_clone_server
"${SERVER}" &&
719 git clone
--filter=blob
:limit
=0 "$URL" client
&&
721 git
-C client fsck
&&
723 # Ensure that unneeded blobs are not inadvertently fetched.
724 test_config
-C client remote.origin.promisor
"false" &&
725 git
-C client config
--unset remote.origin.partialclonefilter
&&
726 test_must_fail git
-C client cat-file
-e "$HASH1" &&
728 # But this blob was fetched, because clone performs an initial checkout
729 git
-C client cat-file
-e "$HASH2"
732 test_expect_success
'partial clone' '
733 partial_clone server "file://$(pwd)/server"
736 test_expect_success
'partial clone with -o' '
737 partial_clone_server server &&
738 git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client &&
739 test_cmp_config -C client "blob:limit=0" --get-all remote.blah.partialclonefilter
742 test_expect_success
'partial clone: warn if server does not support object filtering' '
743 rm -rf server client &&
744 test_create_repo server &&
745 test_commit -C server one &&
747 git clone --filter=blob:limit=0 "file://$(pwd)/server" client 2> err &&
749 test_grep "filtering not recognized by server" err
752 test_expect_success
'batch missing blob request during checkout' '
753 rm -rf server client &&
755 test_create_repo server &&
758 git -C server add a b &&
760 git -C server commit -m x &&
763 git -C server add a b &&
764 git -C server commit -m x &&
766 test_config -C server uploadpack.allowfilter 1 &&
767 test_config -C server uploadpack.allowanysha1inwant 1 &&
769 git clone --filter=blob:limit=0 "file://$(pwd)/server" client &&
771 # Ensure that there is only one negotiation by checking that there is
772 # only "done" line sent. ("done" marks the end of negotiation.)
773 GIT_TRACE_PACKET="$(pwd)/trace" \
774 GIT_TRACE2_EVENT="$(pwd)/trace2_event" \
775 git -C client -c trace2.eventNesting=5 checkout HEAD^ &&
776 grep \"key\":\"total_rounds\",\"value\":\"1\" trace2_event >trace_lines &&
777 test_line_count = 1 trace_lines &&
778 grep "fetch> done" trace >done_lines &&
779 test_line_count = 1 done_lines
782 test_expect_success
'batch missing blob request does not inadvertently try to fetch gitlinks' '
783 rm -rf server client &&
785 test_create_repo repo_for_submodule &&
786 test_commit -C repo_for_submodule x &&
788 test_create_repo server &&
791 git -C server add a b &&
792 git -C server commit -m x &&
796 # Also add a gitlink pointing to an arbitrary repository
797 test_config_global protocol.file.allow always &&
798 git -C server submodule add "$(pwd)/repo_for_submodule" c &&
799 git -C server add a b c &&
800 git -C server commit -m x &&
802 test_config -C server uploadpack.allowfilter 1 &&
803 test_config -C server uploadpack.allowanysha1inwant 1 &&
805 # Make sure that it succeeds
806 git clone --filter=blob:limit=0 "file://$(pwd)/server" client
809 .
"$TEST_DIRECTORY"/lib-httpd.sh
812 test_expect_success
'clone with includeIf' '
813 test_when_finished "rm -rf repo \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\"" &&
814 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
816 test_when_finished "rm \"$HOME\"/.gitconfig" &&
817 cat >"$HOME"/.gitconfig <<-EOF &&
818 [includeIf "onbranch:something"]
819 path = /does/not/exist.inc
821 git clone $HTTPD_URL/smart/repo.git repo
824 test_expect_success
'partial clone using HTTP' '
825 partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
828 test_expect_success
'reject cloning shallow repository using HTTP' '
829 test_when_finished "rm -rf repo" &&
830 git clone --bare --no-local --depth=1 src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
831 test_must_fail git -c protocol.version=2 clone --reject-shallow $HTTPD_URL/smart/repo.git repo 2>err &&
832 test_grep -e "source repository is shallow, reject to clone." err &&
834 git clone --no-reject-shallow $HTTPD_URL/smart/repo.git repo
837 test_expect_success
'auto-discover bundle URI from HTTP clone' '
838 test_when_finished rm -rf trace.txt repo2 "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
839 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/everything.bundle" --all &&
840 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
842 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
843 uploadpack.advertiseBundleURIs true &&
844 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
846 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
848 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
849 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
851 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
852 git -c protocol.version=2 \
853 -c transfer.bundleURI=true clone \
854 $HTTPD_URL/smart/repo2.git repo2 &&
855 cat >pattern <<-EOF &&
856 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
858 grep -f pattern trace.txt
861 test_expect_success
'auto-discover multiple bundles from HTTP clone' '
862 test_when_finished rm -rf trace.txt repo3 "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
864 test_commit -C src new &&
865 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/new.bundle" HEAD~1..HEAD &&
866 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
868 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
869 uploadpack.advertiseBundleURIs true &&
870 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
872 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
875 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
876 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
877 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
878 bundle.new.uri "$HTTPD_URL/new.bundle" &&
880 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
881 git -c protocol.version=2 \
882 -c transfer.bundleURI=true clone \
883 $HTTPD_URL/smart/repo3.git repo3 &&
885 # We should fetch _both_ bundles
886 cat >pattern <<-EOF &&
887 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
889 grep -f pattern trace.txt &&
890 cat >pattern <<-EOF &&
891 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/new.bundle"\]
893 grep -f pattern trace.txt
896 test_expect_success
'auto-discover multiple bundles from HTTP clone: creationToken heuristic' '
897 test_when_finished rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
898 test_when_finished rm -rf clone-heuristic trace*.txt &&
900 test_commit -C src newest &&
901 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/newest.bundle" HEAD~1..HEAD &&
902 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
904 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/repo4.git/config" <<-EOF &&
906 advertiseBundleURIs = true
911 heuristic = creationToken
913 [bundle "everything"]
914 uri = $HTTPD_URL/everything.bundle
918 uri = $HTTPD_URL/new.bundle
922 uri = $HTTPD_URL/newest.bundle
926 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \
927 git -c protocol.version=2 \
928 -c transfer.bundleURI=true clone \
929 "$HTTPD_URL/smart/repo4.git" clone-heuristic &&
931 cat >expect <<-EOF &&
932 $HTTPD_URL/newest.bundle
933 $HTTPD_URL/new.bundle
934 $HTTPD_URL/everything.bundle
937 # We should fetch all bundles in the expected order.
938 test_remote_https_urls <trace-clone.txt >actual &&
939 test_cmp expect actual
942 # DO NOT add non-httpd-specific tests here, because the last part of this
943 # test script is only executed when httpd is available and enabled.