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
534 for repo
in rep rep
/home
/project
123
536 test_expect_success
"clone [::1]:$repo" '
537 test_clone_url [::1]:$repo ::1 "$repo"
541 test_expect_success
"clone host:/~repo" '
542 test_clone_url host:/~repo host "~repo"
545 test_expect_success
"clone [::1]:/~repo" '
546 test_clone_url [::1]:/~repo ::1 "~repo"
550 for url
in foo
/bar
:baz
[foo
]bar
/baz
:qux
[foo
/bar
]:baz
552 test_expect_success
"clone $url is not ssh" '
553 test_clone_url $url none
558 #ignore trailing colon
561 test_expect_success
"clone ssh://host.xz$tcol/home/user/repo" '
562 test_clone_url "ssh://host.xz$tcol/home/user/repo" host.xz /home/user/repo
564 # from home directory
565 test_expect_success
"clone ssh://host.xz$tcol/~repo" '
566 test_clone_url "ssh://host.xz$tcol/~repo" host.xz "~repo"
571 test_expect_success
'clone ssh://host.xz:22/home/user/repo' '
572 test_clone_url "ssh://host.xz:22/home/user/repo" "-p 22 host.xz" "/home/user/repo"
575 # from home directory with port number
576 test_expect_success
'clone ssh://host.xz:22/~repo' '
577 test_clone_url "ssh://host.xz:22/~repo" "-p 22 host.xz" "~repo"
581 for tuah
in ::1 [::1] [::1]: user@
::1 user@
[::1] user@
[::1]: [user@
::1] [user@
::1]:
583 ehost
=$
(echo $tuah |
sed -e "s/1]:/1]/" |
tr -d "[]")
584 test_expect_success
"clone ssh://$tuah/home/user/repo" "
585 test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
589 #IPv6 from home directory
590 for tuah
in ::1 [::1] user@
::1 user@
[::1] [user@
::1]
592 euah
=$
(echo $tuah |
tr -d "[]")
593 test_expect_success
"clone ssh://$tuah/~repo" "
594 test_clone_url ssh://$tuah/~repo $euah '~repo'
598 #IPv6 with port number
599 for tuah
in [::1] user@
[::1] [user@
::1]
601 euah
=$
(echo $tuah |
tr -d "[]")
602 test_expect_success
"clone ssh://$tuah:22/home/user/repo" "
603 test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
607 #IPv6 from home directory with port number
608 for tuah
in [::1] user@
[::1] [user@
::1]
610 euah
=$
(echo $tuah |
tr -d "[]")
611 test_expect_success
"clone ssh://$tuah:22/~repo" "
612 test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
616 test_expect_success
'clone from a repository with two identical branches' '
620 git checkout -b another main
622 git clone src target-11 &&
623 test "z$( cd target-11 && git symbolic-ref HEAD )" = zrefs/heads/another
627 test_expect_success
'shallow clone locally' '
628 git clone --depth=1 --no-local src ssrrcc &&
629 git clone ssrrcc ddsstt &&
630 test_cmp ssrrcc/.git/shallow ddsstt/.git/shallow &&
631 ( cd ddsstt && git fsck )
634 test_expect_success
'GIT_TRACE_PACKFILE produces a usable pack' '
636 GIT_TRACE_PACKFILE=$PWD/tmp.pack git clone --no-local --bare src dst.git &&
637 git init --bare replay.git &&
638 git -C replay.git index-pack -v --stdin <tmp.pack
641 test_expect_success
'clone on case-insensitive fs' '
645 o=$(git hash-object -w --stdin </dev/null | hex2oct) &&
646 t=$(printf "100644 X\0${o}100644 x\0${o}" |
647 git hash-object -w -t tree --stdin) &&
648 c=$(git commit-tree -m bogus $t) &&
649 git update-ref refs/heads/bogus $c &&
650 git clone -b bogus . bogus 2>warning
654 test_expect_success CASE_INSENSITIVE_FS
'colliding file detection' '
655 grep X icasefs/warning &&
656 grep x icasefs/warning &&
657 test_grep "the following paths have collided" icasefs/warning
660 test_expect_success CASE_INSENSITIVE_FS
,SYMLINKS \
661 'colliding symlink/directory keeps directory' '
662 git init icasefs-colliding-symlink &&
664 cd icasefs-colliding-symlink &&
665 a=$(printf a | git hash-object -w --stdin) &&
666 printf "100644 %s 0\tA/dir/b\n120000 %s 0\ta\n" $a $a >idx &&
667 git update-index --index-info <idx &&
669 git commit -m initial
671 git clone icasefs-colliding-symlink icasefs-colliding-symlink-clone &&
672 test_file_not_empty icasefs-colliding-symlink-clone/A/dir/b
675 test_expect_success
'clone with GIT_DEFAULT_HASH' '
677 sane_unset GIT_DEFAULT_HASH &&
678 git init --object-format=sha1 test-sha1 &&
679 git init --object-format=sha256 test-sha256
681 test_commit -C test-sha1 foo &&
682 test_commit -C test-sha256 foo &&
683 GIT_DEFAULT_HASH=sha1 git clone test-sha256 test-clone-sha256 &&
684 GIT_DEFAULT_HASH=sha256 git clone test-sha1 test-clone-sha1 &&
685 git -C test-clone-sha1 status &&
686 git -C test-clone-sha256 status
689 partial_clone_server
() {
692 rm -rf "$SERVER" client
&&
693 test_create_repo
"$SERVER" &&
694 test_commit
-C "$SERVER" one
&&
695 HASH1
=$
(git
-C "$SERVER" hash-object one.t
) &&
696 git
-C "$SERVER" revert HEAD
&&
697 test_commit
-C "$SERVER" two
&&
698 HASH2
=$
(git
-C "$SERVER" hash-object two.t
) &&
699 test_config
-C "$SERVER" uploadpack.allowfilter
1 &&
700 test_config
-C "$SERVER" uploadpack.allowanysha1inwant
1
707 partial_clone_server
"${SERVER}" &&
708 git clone
--filter=blob
:limit
=0 "$URL" client
&&
710 git
-C client fsck
&&
712 # Ensure that unneeded blobs are not inadvertently fetched.
713 test_config
-C client remote.origin.promisor
"false" &&
714 git
-C client config
--unset remote.origin.partialclonefilter
&&
715 test_must_fail git
-C client cat-file
-e "$HASH1" &&
717 # But this blob was fetched, because clone performs an initial checkout
718 git
-C client cat-file
-e "$HASH2"
721 test_expect_success
'partial clone' '
722 partial_clone server "file://$(pwd)/server"
725 test_expect_success
'partial clone with -o' '
726 partial_clone_server server &&
727 git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client &&
728 test_cmp_config -C client "blob:limit=0" --get-all remote.blah.partialclonefilter
731 test_expect_success
'partial clone: warn if server does not support object filtering' '
732 rm -rf server client &&
733 test_create_repo server &&
734 test_commit -C server one &&
736 git clone --filter=blob:limit=0 "file://$(pwd)/server" client 2> err &&
738 test_grep "filtering not recognized by server" err
741 test_expect_success
'batch missing blob request during checkout' '
742 rm -rf server client &&
744 test_create_repo server &&
747 git -C server add a b &&
749 git -C server commit -m x &&
752 git -C server add a b &&
753 git -C server commit -m x &&
755 test_config -C server uploadpack.allowfilter 1 &&
756 test_config -C server uploadpack.allowanysha1inwant 1 &&
758 git clone --filter=blob:limit=0 "file://$(pwd)/server" client &&
760 # Ensure that there is only one negotiation by checking that there is
761 # only "done" line sent. ("done" marks the end of negotiation.)
762 GIT_TRACE_PACKET="$(pwd)/trace" \
763 GIT_TRACE2_EVENT="$(pwd)/trace2_event" \
764 git -C client -c trace2.eventNesting=5 checkout HEAD^ &&
765 grep \"key\":\"total_rounds\",\"value\":\"1\" trace2_event >trace_lines &&
766 test_line_count = 1 trace_lines &&
767 grep "fetch> done" trace >done_lines &&
768 test_line_count = 1 done_lines
771 test_expect_success
'batch missing blob request does not inadvertently try to fetch gitlinks' '
772 rm -rf server client &&
774 test_create_repo repo_for_submodule &&
775 test_commit -C repo_for_submodule x &&
777 test_create_repo server &&
780 git -C server add a b &&
781 git -C server commit -m x &&
785 # Also add a gitlink pointing to an arbitrary repository
786 test_config_global protocol.file.allow always &&
787 git -C server submodule add "$(pwd)/repo_for_submodule" c &&
788 git -C server add a b c &&
789 git -C server commit -m x &&
791 test_config -C server uploadpack.allowfilter 1 &&
792 test_config -C server uploadpack.allowanysha1inwant 1 &&
794 # Make sure that it succeeds
795 git clone --filter=blob:limit=0 "file://$(pwd)/server" client
798 .
"$TEST_DIRECTORY"/lib-httpd.sh
801 test_expect_success
'clone with includeIf' '
802 test_when_finished "rm -rf repo \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\"" &&
803 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
805 test_when_finished "rm \"$HOME\"/.gitconfig" &&
806 cat >"$HOME"/.gitconfig <<-EOF &&
807 [includeIf "onbranch:something"]
808 path = /does/not/exist.inc
810 git clone $HTTPD_URL/smart/repo.git repo
813 test_expect_success
'partial clone using HTTP' '
814 partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
817 test_expect_success
'reject cloning shallow repository using HTTP' '
818 test_when_finished "rm -rf repo" &&
819 git clone --bare --no-local --depth=1 src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
820 test_must_fail git -c protocol.version=2 clone --reject-shallow $HTTPD_URL/smart/repo.git repo 2>err &&
821 test_grep -e "source repository is shallow, reject to clone." err &&
823 git clone --no-reject-shallow $HTTPD_URL/smart/repo.git repo
826 test_expect_success
'auto-discover bundle URI from HTTP clone' '
827 test_when_finished rm -rf trace.txt repo2 "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
828 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/everything.bundle" --all &&
829 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
831 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
832 uploadpack.advertiseBundleURIs true &&
833 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
835 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
837 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
838 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
840 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
841 git -c protocol.version=2 \
842 -c transfer.bundleURI=true clone \
843 $HTTPD_URL/smart/repo2.git repo2 &&
844 cat >pattern <<-EOF &&
845 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
847 grep -f pattern trace.txt
850 test_expect_success
'auto-discover multiple bundles from HTTP clone' '
851 test_when_finished rm -rf trace.txt repo3 "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
853 test_commit -C src new &&
854 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/new.bundle" HEAD~1..HEAD &&
855 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
857 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
858 uploadpack.advertiseBundleURIs true &&
859 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
861 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
864 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
865 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
866 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
867 bundle.new.uri "$HTTPD_URL/new.bundle" &&
869 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
870 git -c protocol.version=2 \
871 -c transfer.bundleURI=true clone \
872 $HTTPD_URL/smart/repo3.git repo3 &&
874 # We should fetch _both_ bundles
875 cat >pattern <<-EOF &&
876 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
878 grep -f pattern trace.txt &&
879 cat >pattern <<-EOF &&
880 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/new.bundle"\]
882 grep -f pattern trace.txt
885 test_expect_success
'auto-discover multiple bundles from HTTP clone: creationToken heuristic' '
886 test_when_finished rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
887 test_when_finished rm -rf clone-heuristic trace*.txt &&
889 test_commit -C src newest &&
890 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/newest.bundle" HEAD~1..HEAD &&
891 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
893 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/repo4.git/config" <<-EOF &&
895 advertiseBundleURIs = true
900 heuristic = creationToken
902 [bundle "everything"]
903 uri = $HTTPD_URL/everything.bundle
907 uri = $HTTPD_URL/new.bundle
911 uri = $HTTPD_URL/newest.bundle
915 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \
916 git -c protocol.version=2 \
917 -c transfer.bundleURI=true clone \
918 "$HTTPD_URL/smart/repo4.git" clone-heuristic &&
920 cat >expect <<-EOF &&
921 $HTTPD_URL/newest.bundle
922 $HTTPD_URL/new.bundle
923 $HTTPD_URL/everything.bundle
926 # We should fetch all bundles in the expected order.
927 test_remote_https_urls <trace-clone.txt >actual &&
928 test_cmp expect actual
931 # DO NOT add non-httpd-specific tests here, because the last part of this
932 # test script is only executed when httpd is available and enabled.