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
'clone does not keep pack' '
52 git clone -n "file://$(pwd)/src" dst &&
54 ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
58 test_expect_success
'clone checks out files' '
66 test_expect_success
'clone respects GIT_WORK_TREE' '
68 GIT_WORK_TREE=worktree git clone src bare &&
69 test -f bare/config &&
74 test_expect_success
'clone from hooks' '
76 test_create_repo r0 &&
78 test_commit initial &&
82 test_hook pre-commit <<-\EOF &&
88 test_must_fail git commit -m invoke-hook &&
90 test_cmp r0/.git/HEAD r2/.git/HEAD &&
91 test_cmp r0/initial.t r2/initial.t
95 test_expect_success
'clone creates intermediate directories' '
97 git clone src long/path/to/dst &&
98 test -f long/path/to/dst/file
102 test_expect_success
'clone creates intermediate directories for bare repo' '
104 git clone --bare src long/path/to/bare/dst &&
105 test -f long/path/to/bare/dst/config
109 test_expect_success
'clone --mirror' '
111 git clone --mirror src mirror &&
112 test -f mirror/HEAD &&
113 test ! -f mirror/file &&
114 FETCH="$(cd mirror && git config remote.origin.fetch)" &&
115 test "+refs/*:refs/*" = "$FETCH" &&
116 MIRROR="$(cd mirror && git config --bool remote.origin.mirror)" &&
117 test "$MIRROR" = true
121 test_expect_success
'clone --mirror with detached HEAD' '
123 ( cd src && git checkout HEAD^ && git rev-parse HEAD >../expected ) &&
124 git clone --mirror src mirror.detached &&
125 ( cd src && git checkout - ) &&
126 GIT_DIR=mirror.detached git rev-parse HEAD >actual &&
127 test_cmp expected actual
131 test_expect_success
'clone --bare with detached HEAD' '
133 ( cd src && git checkout HEAD^ && git rev-parse HEAD >../expected ) &&
134 git clone --bare src bare.detached &&
135 ( cd src && git checkout - ) &&
136 GIT_DIR=bare.detached git rev-parse HEAD >actual &&
137 test_cmp expected actual
141 test_expect_success
'clone --bare names the local repository <name>.git' '
143 git clone --bare src &&
148 test_expect_success
'clone --mirror does not repeat tags' '
151 git tag some-tag HEAD) &&
152 git clone --mirror src mirror2 &&
154 git show-ref 2> clone.err > clone.out) &&
155 ! grep Duplicate mirror2/clone.err &&
156 grep some-tag mirror2/clone.out
160 test_expect_success
'clone with files ref format' '
161 test_when_finished "rm -rf ref-storage" &&
162 git clone --ref-format=files --mirror src ref-storage &&
163 echo files >expect &&
164 git -C ref-storage rev-parse --show-ref-format >actual &&
165 test_cmp expect actual
168 test_expect_success
'clone with garbage ref format' '
169 cat >expect <<-EOF &&
170 fatal: unknown ref storage format ${SQ}garbage${SQ}
172 test_must_fail git clone --ref-format=garbage --mirror src ref-storage 2>err &&
173 test_cmp expect err &&
174 test_path_is_missing ref-storage
177 test_expect_success
'clone to destination with trailing /' '
179 git clone src target-1/ &&
180 T=$( cd target-1 && git rev-parse HEAD ) &&
181 S=$( cd src && git rev-parse HEAD ) &&
186 test_expect_success
'clone to destination with extra trailing /' '
188 git clone src target-2/// &&
189 T=$( cd target-2 && git rev-parse HEAD ) &&
190 S=$( cd src && git rev-parse HEAD ) &&
195 test_expect_success
'clone to an existing empty directory' '
197 git clone src target-3 &&
198 T=$( cd target-3 && git rev-parse HEAD ) &&
199 S=$( cd src && git rev-parse HEAD ) &&
203 test_expect_success
'clone to an existing non-empty directory' '
205 >target-4/Fakefile &&
206 test_must_fail git clone src target-4
209 test_expect_success
'clone to an existing path' '
211 test_must_fail git clone src target-5
214 test_expect_success
'clone a void' '
219 git clone "file://$(pwd)/src-0" target-6 2>err-6 &&
220 ! grep "fatal:" err-6 &&
222 cd src-0 && test_commit A
224 git clone "file://$(pwd)/src-0" target-7 2>err-7 &&
225 ! grep "fatal:" err-7 &&
226 # There is no reason to insist they are bit-for-bit
227 # identical, but this test should suffice for now.
228 test_cmp target-6/.git/config target-7/.git/config
231 test_expect_success
'clone respects global branch.autosetuprebase' '
233 test_config="$HOME/.gitconfig" &&
234 git config -f "$test_config" branch.autosetuprebase remote &&
238 actual="z$(git config branch.main.rebase)" &&
243 test_expect_success
'respect url-encoding of file://' '
245 git clone "file://$PWD/x+y" xy-url-1 &&
246 git clone "file://$PWD/x%2By" xy-url-2
249 test_expect_success
'do not query-string-decode + in URLs' '
252 test_must_fail git clone "file://$PWD/x+y" xy-no-plus
255 test_expect_success
'do not respect url-encoding of non-url path' '
257 test_must_fail git clone x%2By xy-regular &&
258 git clone x+y xy-regular
261 test_expect_success
'clone separate gitdir' '
263 git clone --separate-git-dir realgitdir src dst &&
264 test -d realgitdir/refs
267 test_expect_success
'clone separate gitdir: output' '
268 echo "gitdir: $(pwd)/realgitdir" >expected &&
269 test_cmp expected dst/.git
272 test_expect_success
'clone from .git file' '
273 git clone dst/.git dst2
276 test_expect_success
'fetch from .git gitfile' '
279 git fetch ../dst/.git
283 test_expect_success
'fetch from gitfile parent' '
290 test_expect_success
'clone separate gitdir where target already exists' '
292 echo foo=bar >>realgitdir/config &&
293 test_must_fail git clone --separate-git-dir realgitdir src dst &&
294 grep foo=bar realgitdir/config
297 test_expect_success
'clone --reference from original' '
298 git clone --shared --bare src src-1 &&
299 git clone --bare src src-2 &&
300 git clone --reference=src-2 --bare src-1 target-8 &&
301 grep /src-2/ target-8/objects/info/alternates
304 test_expect_success
'clone with more than one --reference' '
305 git clone --bare src src-3 &&
306 git clone --bare src src-4 &&
307 git clone --reference=src-3 --reference=src-4 src target-9 &&
308 grep /src-3/ target-9/.git/objects/info/alternates &&
309 grep /src-4/ target-9/.git/objects/info/alternates
312 test_expect_success
'clone from original with relative alternate' '
314 git clone --bare src nest/src-5 &&
315 echo ../../../src/.git/objects >nest/src-5/objects/info/alternates &&
316 git clone --bare nest/src-5 target-10 &&
317 grep /src/\\.git/objects target-10/objects/info/alternates
320 test_expect_success
'clone checking out a tag' '
321 git clone --branch=some-tag src dst.tag &&
322 GIT_DIR=src/.git git rev-parse some-tag >expected &&
323 GIT_DIR=dst.tag/.git git rev-parse HEAD >actual &&
324 test_cmp expected actual &&
325 GIT_DIR=dst.tag/.git git config remote.origin.fetch >fetch.actual &&
326 echo "+refs/heads/*:refs/remotes/origin/*" >fetch.expected &&
327 test_cmp fetch.expected fetch.actual
330 test_expect_success
'set up ssh wrapper' '
331 cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" \
332 "$TRASH_DIRECTORY/ssh$X" &&
333 GIT_SSH="$TRASH_DIRECTORY/ssh$X" &&
335 export TRASH_DIRECTORY &&
336 >"$TRASH_DIRECTORY"/ssh-output
339 copy_ssh_wrapper_as
() {
341 cp "$TRASH_DIRECTORY/ssh$X" "${1%$X}$X" &&
342 test_when_finished
"rm $(git rev-parse --sq-quote "${1%$X}$X")" &&
343 GIT_SSH
="${1%$X}$X" &&
344 test_when_finished
"GIT_SSH=\"\$TRASH_DIRECTORY/ssh\$X\""
349 (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
356 echo "ssh: $1 git-upload-pack '$2'"
359 echo "ssh: $1 $2 git-upload-pack '$3'"
362 echo "ssh: $1 $2 git-upload-pack '$3' $4"
364 } >"$TRASH_DIRECTORY/ssh-expect" &&
365 (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output
)
368 test_expect_success
'clone myhost:src uses ssh' '
369 GIT_TEST_PROTOCOL_VERSION=0 git clone myhost:src ssh-clone &&
370 expect_ssh myhost src
373 test_expect_success
!MINGW
,!CYGWIN
'clone local path foo:bar' '
374 cp -R src "foo:bar" &&
375 git clone "foo:bar" foobar &&
379 test_expect_success
'bracketed hostnames are still ssh' '
380 GIT_TEST_PROTOCOL_VERSION=0 git clone "[myhost:123]:src" ssh-bracket-clone &&
381 expect_ssh "-p 123" myhost src
384 test_expect_success
'OpenSSH variant passes -4' '
385 GIT_TEST_PROTOCOL_VERSION=0 git clone -4 "[myhost:123]:src" ssh-ipv4-clone &&
386 expect_ssh "-4 -p 123" myhost src
389 test_expect_success
'variant can be overridden' '
390 copy_ssh_wrapper_as "$TRASH_DIRECTORY/putty" &&
391 git -c ssh.variant=putty clone -4 "[myhost:123]:src" ssh-putty-clone &&
392 expect_ssh "-4 -P 123" myhost src
395 test_expect_success
'variant=auto picks based on basename' '
396 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
397 git -c ssh.variant=auto clone -4 "[myhost:123]:src" ssh-auto-clone &&
398 expect_ssh "-4 -P 123" myhost src
401 test_expect_success
'simple does not support -4/-6' '
402 copy_ssh_wrapper_as "$TRASH_DIRECTORY/simple" &&
403 test_must_fail git clone -4 "myhost:src" ssh-4-clone-simple
406 test_expect_success
'simple does not support port' '
407 copy_ssh_wrapper_as "$TRASH_DIRECTORY/simple" &&
408 test_must_fail git clone "[myhost:123]:src" ssh-bracket-clone-simple
411 test_expect_success
'uplink is treated as simple' '
412 copy_ssh_wrapper_as "$TRASH_DIRECTORY/uplink" &&
413 test_must_fail git clone "[myhost:123]:src" ssh-bracket-clone-uplink &&
414 git clone "myhost:src" ssh-clone-uplink &&
415 expect_ssh myhost src
418 test_expect_success
'OpenSSH-like uplink is treated as ssh' '
419 write_script "$TRASH_DIRECTORY/uplink" <<-EOF &&
424 exec "\$TRASH_DIRECTORY/ssh$X" "\$@"
426 test_when_finished "rm -f \"\$TRASH_DIRECTORY/uplink\"" &&
427 GIT_SSH="$TRASH_DIRECTORY/uplink" &&
428 test_when_finished "GIT_SSH=\"\$TRASH_DIRECTORY/ssh\$X\"" &&
429 GIT_TEST_PROTOCOL_VERSION=0 git clone "[myhost:123]:src" ssh-bracket-clone-sshlike-uplink &&
430 expect_ssh "-p 123" myhost src
433 test_expect_success
'plink is treated specially (as putty)' '
434 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
435 git clone "[myhost:123]:src" ssh-bracket-clone-plink-0 &&
436 expect_ssh "-P 123" myhost src
439 test_expect_success
'plink.exe is treated specially (as putty)' '
440 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" &&
441 git clone "[myhost:123]:src" ssh-bracket-clone-plink-1 &&
442 expect_ssh "-P 123" myhost src
445 test_expect_success
'tortoiseplink is like putty, with extra arguments' '
446 copy_ssh_wrapper_as "$TRASH_DIRECTORY/tortoiseplink" &&
447 git clone "[myhost:123]:src" ssh-bracket-clone-plink-2 &&
448 expect_ssh "-batch -P 123" myhost src
451 test_expect_success
'double quoted plink.exe in GIT_SSH_COMMAND' '
452 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" &&
453 GIT_SSH_COMMAND="\"$TRASH_DIRECTORY/plink.exe\" -v" \
454 git clone "[myhost:123]:src" ssh-bracket-clone-plink-3 &&
455 expect_ssh "-v -P 123" myhost src
458 test_expect_success
'single quoted plink.exe in GIT_SSH_COMMAND' '
459 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" &&
460 GIT_SSH_COMMAND="$SQ$TRASH_DIRECTORY/plink.exe$SQ -v" \
461 git clone "[myhost:123]:src" ssh-bracket-clone-plink-4 &&
462 expect_ssh "-v -P 123" myhost src
465 test_expect_success
'GIT_SSH_VARIANT overrides plink detection' '
466 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
467 GIT_TEST_PROTOCOL_VERSION=0 GIT_SSH_VARIANT=ssh \
468 git clone "[myhost:123]:src" ssh-bracket-clone-variant-1 &&
469 expect_ssh "-p 123" myhost src
472 test_expect_success
'ssh.variant overrides plink detection' '
473 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
474 GIT_TEST_PROTOCOL_VERSION=0 git -c ssh.variant=ssh \
475 clone "[myhost:123]:src" ssh-bracket-clone-variant-2 &&
476 expect_ssh "-p 123" myhost src
479 test_expect_success
'GIT_SSH_VARIANT overrides plink detection to plink' '
480 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
481 GIT_SSH_VARIANT=plink \
482 git clone "[myhost:123]:src" ssh-bracket-clone-variant-3 &&
483 expect_ssh "-P 123" myhost src
486 test_expect_success
'GIT_SSH_VARIANT overrides plink to tortoiseplink' '
487 copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
488 GIT_SSH_VARIANT=tortoiseplink \
489 git clone "[myhost:123]:src" ssh-bracket-clone-variant-4 &&
490 expect_ssh "-batch -P 123" myhost src
493 test_expect_success
'clean failure on broken quoting' '
495 env GIT_SSH_COMMAND="${SQ}plink.exe -v" \
496 git clone "[myhost:123]:src" sq-failure
504 counter
=$
(($counter + 1))
505 test_might_fail env GIT_TEST_PROTOCOL_VERSION
=0 git clone
"$1" tmp
$counter &&
510 test_expect_success
!MINGW
,!CYGWIN
'clone c:temp is ssl' '
511 test_clone_url c:temp c temp
514 test_expect_success MINGW
'clone c:temp is dos drive' '
515 test_clone_url c:temp none
519 for repo
in rep rep
/home
/project
123
521 test_expect_success
"clone host:$repo" '
522 test_clone_url host:$repo host $repo
527 for repo
in rep rep
/home
/project
123
529 test_expect_success
"clone [::1]:$repo" '
530 test_clone_url [::1]:$repo ::1 "$repo"
534 test_expect_success
"clone host:/~repo" '
535 test_clone_url host:/~repo host "~repo"
538 test_expect_success
"clone [::1]:/~repo" '
539 test_clone_url [::1]:/~repo ::1 "~repo"
543 for url
in foo
/bar
:baz
[foo
]bar
/baz
:qux
[foo
/bar
]:baz
545 test_expect_success
"clone $url is not ssh" '
546 test_clone_url $url none
551 #ignore trailing colon
554 test_expect_success
"clone ssh://host.xz$tcol/home/user/repo" '
555 test_clone_url "ssh://host.xz$tcol/home/user/repo" host.xz /home/user/repo
557 # from home directory
558 test_expect_success
"clone ssh://host.xz$tcol/~repo" '
559 test_clone_url "ssh://host.xz$tcol/~repo" host.xz "~repo"
564 test_expect_success
'clone ssh://host.xz:22/home/user/repo' '
565 test_clone_url "ssh://host.xz:22/home/user/repo" "-p 22 host.xz" "/home/user/repo"
568 # from home directory with port number
569 test_expect_success
'clone ssh://host.xz:22/~repo' '
570 test_clone_url "ssh://host.xz:22/~repo" "-p 22 host.xz" "~repo"
574 for tuah
in ::1 [::1] [::1]: user@
::1 user@
[::1] user@
[::1]: [user@
::1] [user@
::1]:
576 ehost
=$
(echo $tuah |
sed -e "s/1]:/1]/" |
tr -d "[]")
577 test_expect_success
"clone ssh://$tuah/home/user/repo" "
578 test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
582 #IPv6 from home directory
583 for tuah
in ::1 [::1] user@
::1 user@
[::1] [user@
::1]
585 euah
=$
(echo $tuah |
tr -d "[]")
586 test_expect_success
"clone ssh://$tuah/~repo" "
587 test_clone_url ssh://$tuah/~repo $euah '~repo'
591 #IPv6 with port number
592 for tuah
in [::1] user@
[::1] [user@
::1]
594 euah
=$
(echo $tuah |
tr -d "[]")
595 test_expect_success
"clone ssh://$tuah:22/home/user/repo" "
596 test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
600 #IPv6 from home directory with port number
601 for tuah
in [::1] user@
[::1] [user@
::1]
603 euah
=$
(echo $tuah |
tr -d "[]")
604 test_expect_success
"clone ssh://$tuah:22/~repo" "
605 test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
609 test_expect_success
'clone from a repository with two identical branches' '
613 git checkout -b another main
615 git clone src target-11 &&
616 test "z$( cd target-11 && git symbolic-ref HEAD )" = zrefs/heads/another
620 test_expect_success
'shallow clone locally' '
621 git clone --depth=1 --no-local src ssrrcc &&
622 git clone ssrrcc ddsstt &&
623 test_cmp ssrrcc/.git/shallow ddsstt/.git/shallow &&
624 ( cd ddsstt && git fsck )
627 test_expect_success
'GIT_TRACE_PACKFILE produces a usable pack' '
629 GIT_TRACE_PACKFILE=$PWD/tmp.pack git clone --no-local --bare src dst.git &&
630 git init --bare replay.git &&
631 git -C replay.git index-pack -v --stdin <tmp.pack
634 test_expect_success
'clone on case-insensitive fs' '
638 o=$(git hash-object -w --stdin </dev/null | hex2oct) &&
639 t=$(printf "100644 X\0${o}100644 x\0${o}" |
640 git hash-object -w -t tree --stdin) &&
641 c=$(git commit-tree -m bogus $t) &&
642 git update-ref refs/heads/bogus $c &&
643 git clone -b bogus . bogus 2>warning
647 test_expect_success CASE_INSENSITIVE_FS
'colliding file detection' '
648 grep X icasefs/warning &&
649 grep x icasefs/warning &&
650 test_grep "the following paths have collided" icasefs/warning
653 test_expect_success
'clone with GIT_DEFAULT_HASH' '
655 sane_unset GIT_DEFAULT_HASH &&
656 git init --object-format=sha1 test-sha1 &&
657 git init --object-format=sha256 test-sha256
659 test_commit -C test-sha1 foo &&
660 test_commit -C test-sha256 foo &&
661 GIT_DEFAULT_HASH=sha1 git clone test-sha256 test-clone-sha256 &&
662 GIT_DEFAULT_HASH=sha256 git clone test-sha1 test-clone-sha1 &&
663 git -C test-clone-sha1 status &&
664 git -C test-clone-sha256 status
667 partial_clone_server
() {
670 rm -rf "$SERVER" client
&&
671 test_create_repo
"$SERVER" &&
672 test_commit
-C "$SERVER" one
&&
673 HASH1
=$
(git
-C "$SERVER" hash-object one.t
) &&
674 git
-C "$SERVER" revert HEAD
&&
675 test_commit
-C "$SERVER" two
&&
676 HASH2
=$
(git
-C "$SERVER" hash-object two.t
) &&
677 test_config
-C "$SERVER" uploadpack.allowfilter
1 &&
678 test_config
-C "$SERVER" uploadpack.allowanysha1inwant
1
685 partial_clone_server
"${SERVER}" &&
686 git clone
--filter=blob
:limit
=0 "$URL" client
&&
688 git
-C client fsck
&&
690 # Ensure that unneeded blobs are not inadvertently fetched.
691 test_config
-C client remote.origin.promisor
"false" &&
692 git
-C client config
--unset remote.origin.partialclonefilter
&&
693 test_must_fail git
-C client cat-file
-e "$HASH1" &&
695 # But this blob was fetched, because clone performs an initial checkout
696 git
-C client cat-file
-e "$HASH2"
699 test_expect_success
'partial clone' '
700 partial_clone server "file://$(pwd)/server"
703 test_expect_success
'partial clone with -o' '
704 partial_clone_server server &&
705 git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client &&
706 test_cmp_config -C client "blob:limit=0" --get-all remote.blah.partialclonefilter
709 test_expect_success
'partial clone: warn if server does not support object filtering' '
710 rm -rf server client &&
711 test_create_repo server &&
712 test_commit -C server one &&
714 git clone --filter=blob:limit=0 "file://$(pwd)/server" client 2> err &&
716 test_grep "filtering not recognized by server" err
719 test_expect_success
'batch missing blob request during checkout' '
720 rm -rf server client &&
722 test_create_repo server &&
725 git -C server add a b &&
727 git -C server commit -m x &&
730 git -C server add a b &&
731 git -C server commit -m x &&
733 test_config -C server uploadpack.allowfilter 1 &&
734 test_config -C server uploadpack.allowanysha1inwant 1 &&
736 git clone --filter=blob:limit=0 "file://$(pwd)/server" client &&
738 # Ensure that there is only one negotiation by checking that there is
739 # only "done" line sent. ("done" marks the end of negotiation.)
740 GIT_TRACE_PACKET="$(pwd)/trace" \
741 GIT_TRACE2_EVENT="$(pwd)/trace2_event" \
742 git -C client -c trace2.eventNesting=5 checkout HEAD^ &&
743 grep \"key\":\"total_rounds\",\"value\":\"1\" trace2_event >trace_lines &&
744 test_line_count = 1 trace_lines &&
745 grep "fetch> done" trace >done_lines &&
746 test_line_count = 1 done_lines
749 test_expect_success
'batch missing blob request does not inadvertently try to fetch gitlinks' '
750 rm -rf server client &&
752 test_create_repo repo_for_submodule &&
753 test_commit -C repo_for_submodule x &&
755 test_create_repo server &&
758 git -C server add a b &&
759 git -C server commit -m x &&
763 # Also add a gitlink pointing to an arbitrary repository
764 test_config_global protocol.file.allow always &&
765 git -C server submodule add "$(pwd)/repo_for_submodule" c &&
766 git -C server add a b c &&
767 git -C server commit -m x &&
769 test_config -C server uploadpack.allowfilter 1 &&
770 test_config -C server uploadpack.allowanysha1inwant 1 &&
772 # Make sure that it succeeds
773 git clone --filter=blob:limit=0 "file://$(pwd)/server" client
776 .
"$TEST_DIRECTORY"/lib-httpd.sh
779 test_expect_success
'partial clone using HTTP' '
780 partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
783 test_expect_success
'reject cloning shallow repository using HTTP' '
784 test_when_finished "rm -rf repo" &&
785 git clone --bare --no-local --depth=1 src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
786 test_must_fail git -c protocol.version=2 clone --reject-shallow $HTTPD_URL/smart/repo.git repo 2>err &&
787 test_grep -e "source repository is shallow, reject to clone." err &&
789 git clone --no-reject-shallow $HTTPD_URL/smart/repo.git repo
792 test_expect_success
'auto-discover bundle URI from HTTP clone' '
793 test_when_finished rm -rf trace.txt repo2 "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
794 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/everything.bundle" --all &&
795 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
797 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
798 uploadpack.advertiseBundleURIs true &&
799 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
801 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
803 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
804 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
806 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
807 git -c protocol.version=2 \
808 -c transfer.bundleURI=true clone \
809 $HTTPD_URL/smart/repo2.git repo2 &&
810 cat >pattern <<-EOF &&
811 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
813 grep -f pattern trace.txt
816 test_expect_success
'auto-discover multiple bundles from HTTP clone' '
817 test_when_finished rm -rf trace.txt repo3 "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
819 test_commit -C src new &&
820 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/new.bundle" HEAD~1..HEAD &&
821 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
823 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
824 uploadpack.advertiseBundleURIs true &&
825 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
827 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
830 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
831 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
832 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
833 bundle.new.uri "$HTTPD_URL/new.bundle" &&
835 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
836 git -c protocol.version=2 \
837 -c transfer.bundleURI=true clone \
838 $HTTPD_URL/smart/repo3.git repo3 &&
840 # We should fetch _both_ bundles
841 cat >pattern <<-EOF &&
842 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
844 grep -f pattern trace.txt &&
845 cat >pattern <<-EOF &&
846 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/new.bundle"\]
848 grep -f pattern trace.txt
851 test_expect_success
'auto-discover multiple bundles from HTTP clone: creationToken heuristic' '
852 test_when_finished rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
853 test_when_finished rm -rf clone-heuristic trace*.txt &&
855 test_commit -C src newest &&
856 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/newest.bundle" HEAD~1..HEAD &&
857 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
859 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/repo4.git/config" <<-EOF &&
861 advertiseBundleURIs = true
866 heuristic = creationToken
868 [bundle "everything"]
869 uri = $HTTPD_URL/everything.bundle
873 uri = $HTTPD_URL/new.bundle
877 uri = $HTTPD_URL/newest.bundle
881 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \
882 git -c protocol.version=2 \
883 -c transfer.bundleURI=true clone \
884 "$HTTPD_URL/smart/repo4.git" clone-heuristic &&
886 cat >expect <<-EOF &&
887 $HTTPD_URL/newest.bundle
888 $HTTPD_URL/new.bundle
889 $HTTPD_URL/everything.bundle
892 # We should fetch all bundles in the expected order.
893 test_remote_https_urls <trace-clone.txt >actual &&
894 test_cmp expect actual
897 # DO NOT add non-httpd-specific tests here, because the last part of this
898 # test script is only executed when httpd is available and enabled.