ci: fix setup of custom path for GitLab CI
[alt-git.git] / t / t5601-clone.sh
blobca431856814e7b48204c8ae0475ed14ce5e78ed7
1 #!/bin/sh
3 test_description=clone
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
11 test_have_prereq !MINGW || X=.exe
13 test_expect_success setup '
15 rm -fr .git &&
16 test_create_repo src &&
18 cd src &&
19 >file &&
20 git add file &&
21 git commit -m initial &&
22 echo 1 >file &&
23 git add file &&
24 git commit -m updated
29 test_expect_success 'clone with excess parameters (1)' '
31 rm -fr dst &&
32 test_must_fail git clone -n src dst junk
36 test_expect_success 'clone with excess parameters (2)' '
38 rm -fr dst &&
39 test_must_fail git clone -n "file://$(pwd)/src" dst junk
43 test_expect_success 'output from clone' '
44 rm -fr dst &&
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' '
51 rm -fr dst &&
52 git clone -n "file://$(pwd)/src" dst &&
53 ! test -f dst/file &&
54 ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
58 test_expect_success 'clone checks out files' '
60 rm -fr dst &&
61 git clone src dst &&
62 test -f dst/file
66 test_expect_success 'clone respects GIT_WORK_TREE' '
68 GIT_WORK_TREE=worktree git clone src bare &&
69 test -f bare/config &&
70 test -f worktree/file
74 test_expect_success 'clone from hooks' '
76 test_create_repo r0 &&
77 cd r0 &&
78 test_commit initial &&
79 cd .. &&
80 git init r1 &&
81 cd r1 &&
82 test_hook pre-commit <<-\EOF &&
83 git clone ../r0 ../r2
84 exit 1
85 EOF
86 : >file &&
87 git add file &&
88 test_must_fail git commit -m invoke-hook &&
89 cd .. &&
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 &&
144 test -d src.git
148 test_expect_success 'clone --mirror does not repeat tags' '
150 (cd src &&
151 git tag some-tag HEAD) &&
152 git clone --mirror src mirror2 &&
153 (cd 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 ) &&
182 test "$T" = "$S"
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 ) &&
191 test "$T" = "$S"
195 test_expect_success 'clone to an existing empty directory' '
196 mkdir target-3 &&
197 git clone src target-3 &&
198 T=$( cd target-3 && git rev-parse HEAD ) &&
199 S=$( cd src && git rev-parse HEAD ) &&
200 test "$T" = "$S"
203 test_expect_success 'clone to an existing non-empty directory' '
204 mkdir target-4 &&
205 >target-4/Fakefile &&
206 test_must_fail git clone src target-4
209 test_expect_success 'clone to an existing path' '
210 >target-5 &&
211 test_must_fail git clone src target-5
214 test_expect_success 'clone a void' '
215 mkdir src-0 &&
217 cd src-0 && git init
218 ) &&
219 git clone "file://$(pwd)/src-0" target-6 2>err-6 &&
220 ! grep "fatal:" err-6 &&
222 cd src-0 && test_commit A
223 ) &&
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 &&
235 rm -fr dst &&
236 git clone src dst &&
237 cd dst &&
238 actual="z$(git config branch.main.rebase)" &&
239 test ztrue = $actual
243 test_expect_success 'respect url-encoding of file://' '
244 git init x+y &&
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' '
250 rm -rf x+y &&
251 git init "x y" &&
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' '
256 git init x+y &&
257 test_must_fail git clone x%2By xy-regular &&
258 git clone x+y xy-regular
261 test_expect_success 'clone separate gitdir' '
262 rm -rf dst &&
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' '
278 cd dst2 &&
279 git fetch ../dst/.git
283 test_expect_success 'fetch from gitfile parent' '
285 cd dst2 &&
286 git fetch ../dst
290 test_expect_success 'clone separate gitdir where target already exists' '
291 rm -rf dst &&
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' '
313 mkdir nest &&
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" &&
334 export GIT_SSH &&
335 export TRASH_DIRECTORY &&
336 >"$TRASH_DIRECTORY"/ssh-output
339 copy_ssh_wrapper_as () {
340 rm -f "${1%$X}$X" &&
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\""
347 expect_ssh () {
348 test_when_finished '
349 (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
350 ' &&
352 case "$#" in
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"
363 esac
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 &&
376 expect_ssh none
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 &&
420 if test "\$1" = "-G"
421 then
422 exit 0
423 fi &&
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' '
494 test_must_fail \
495 env GIT_SSH_COMMAND="${SQ}plink.exe -v" \
496 git clone "[myhost:123]:src" sq-failure
499 counter=0
500 # $1 url
501 # $2 none|host
502 # $3 path
503 test_clone_url () {
504 counter=$(($counter + 1))
505 test_might_fail env GIT_TEST_PROTOCOL_VERSION=0 git clone "$1" tmp$counter &&
506 shift &&
507 expect_ssh "$@"
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
518 #ip v4
519 for repo in rep rep/home/project 123
521 test_expect_success "clone host:$repo" '
522 test_clone_url host:$repo host $repo
524 done
526 #ipv6
527 for repo in rep rep/home/project 123
529 test_expect_success "clone [::1]:$repo" '
530 test_clone_url [::1]:$repo ::1 "$repo"
532 done
533 #home directory
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"
542 # Corner cases
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
548 done
550 #with ssh:// scheme
551 #ignore trailing colon
552 for tcol in "" :
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"
561 done
563 # with port number
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"
573 #IPv6
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
580 done
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'
589 done
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
598 done
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'
607 done
609 test_expect_success 'clone from a repository with two identical branches' '
612 cd src &&
613 git checkout -b another main
614 ) &&
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' '
628 rm -rf dst.git &&
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' '
635 git init icasefs &&
637 cd icasefs &&
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
658 ) &&
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 () {
668 SERVER="$1" &&
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
681 partial_clone () {
682 SERVER="$1" &&
683 URL="$2" &&
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 &&
723 echo a >server/a &&
724 echo b >server/b &&
725 git -C server add a b &&
727 git -C server commit -m x &&
728 echo aa >server/a &&
729 echo bb >server/b &&
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 &&
756 echo a >server/a &&
757 echo b >server/b &&
758 git -C server add a b &&
759 git -C server commit -m x &&
761 echo aa >server/a &&
762 echo bb >server/b &&
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
777 start_httpd
779 test_expect_success 'clone with includeIf' '
780 test_when_finished "rm -rf repo \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\"" &&
781 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
783 test_when_finished "rm \"$HOME\"/.gitconfig" &&
784 cat >"$HOME"/.gitconfig <<-EOF &&
785 [includeIf "onbranch:something"]
786 path = /does/not/exist.inc
788 git clone $HTTPD_URL/smart/repo.git repo
791 test_expect_success 'partial clone using HTTP' '
792 partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
795 test_expect_success 'reject cloning shallow repository using HTTP' '
796 test_when_finished "rm -rf repo" &&
797 git clone --bare --no-local --depth=1 src "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
798 test_must_fail git -c protocol.version=2 clone --reject-shallow $HTTPD_URL/smart/repo.git repo 2>err &&
799 test_grep -e "source repository is shallow, reject to clone." err &&
801 git clone --no-reject-shallow $HTTPD_URL/smart/repo.git repo
804 test_expect_success 'auto-discover bundle URI from HTTP clone' '
805 test_when_finished rm -rf trace.txt repo2 "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
806 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/everything.bundle" --all &&
807 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" &&
809 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
810 uploadpack.advertiseBundleURIs true &&
811 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
812 bundle.version 1 &&
813 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
814 bundle.mode all &&
815 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo2.git" config \
816 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
818 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
819 git -c protocol.version=2 \
820 -c transfer.bundleURI=true clone \
821 $HTTPD_URL/smart/repo2.git repo2 &&
822 cat >pattern <<-EOF &&
823 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
825 grep -f pattern trace.txt
828 test_expect_success 'auto-discover multiple bundles from HTTP clone' '
829 test_when_finished rm -rf trace.txt repo3 "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
831 test_commit -C src new &&
832 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/new.bundle" HEAD~1..HEAD &&
833 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" &&
835 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
836 uploadpack.advertiseBundleURIs true &&
837 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
838 bundle.version 1 &&
839 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
840 bundle.mode all &&
842 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
843 bundle.everything.uri "$HTTPD_URL/everything.bundle" &&
844 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo3.git" config \
845 bundle.new.uri "$HTTPD_URL/new.bundle" &&
847 GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
848 git -c protocol.version=2 \
849 -c transfer.bundleURI=true clone \
850 $HTTPD_URL/smart/repo3.git repo3 &&
852 # We should fetch _both_ bundles
853 cat >pattern <<-EOF &&
854 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\]
856 grep -f pattern trace.txt &&
857 cat >pattern <<-EOF &&
858 "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/new.bundle"\]
860 grep -f pattern trace.txt
863 test_expect_success 'auto-discover multiple bundles from HTTP clone: creationToken heuristic' '
864 test_when_finished rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
865 test_when_finished rm -rf clone-heuristic trace*.txt &&
867 test_commit -C src newest &&
868 git -C src bundle create "$HTTPD_DOCUMENT_ROOT_PATH/newest.bundle" HEAD~1..HEAD &&
869 git clone --bare --no-local src "$HTTPD_DOCUMENT_ROOT_PATH/repo4.git" &&
871 cat >>"$HTTPD_DOCUMENT_ROOT_PATH/repo4.git/config" <<-EOF &&
872 [uploadPack]
873 advertiseBundleURIs = true
875 [bundle]
876 version = 1
877 mode = all
878 heuristic = creationToken
880 [bundle "everything"]
881 uri = $HTTPD_URL/everything.bundle
882 creationtoken = 1
884 [bundle "new"]
885 uri = $HTTPD_URL/new.bundle
886 creationtoken = 2
888 [bundle "newest"]
889 uri = $HTTPD_URL/newest.bundle
890 creationtoken = 3
893 GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \
894 git -c protocol.version=2 \
895 -c transfer.bundleURI=true clone \
896 "$HTTPD_URL/smart/repo4.git" clone-heuristic &&
898 cat >expect <<-EOF &&
899 $HTTPD_URL/newest.bundle
900 $HTTPD_URL/new.bundle
901 $HTTPD_URL/everything.bundle
904 # We should fetch all bundles in the expected order.
905 test_remote_https_urls <trace-clone.txt >actual &&
906 test_cmp expect actual
909 # DO NOT add non-httpd-specific tests here, because the last part of this
910 # test script is only executed when httpd is available and enabled.
912 test_done