diff options
Diffstat (limited to 't/t5616-partial-clone.sh')
-rwxr-xr-x | t/t5616-partial-clone.sh | 195 |
1 files changed, 166 insertions, 29 deletions
diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh index cf3e82b..2da7291 100755 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@ -16,10 +16,10 @@ test_expect_success 'setup normal src repo' ' git init src && for n in 1 2 3 4 do - echo "This is file: $n" > src/file.$n.txt - git -C src add file.$n.txt - git -C src commit -m "file $n" - git -C src ls-files -s file.$n.txt >>temp + echo "This is file: $n" > src/file.$n.txt && + git -C src add file.$n.txt && + git -C src commit -m "file $n" && + git -C src ls-files -s file.$n.txt >>temp || return 1 done && awk -f print_2.awk <temp | sort >expect_1.oids && test_line_count = 4 expect_1.oids @@ -49,6 +49,13 @@ test_expect_success 'do partial clone 1' ' test "$(git -C pc1 config --local remote.origin.partialclonefilter)" = "blob:none" ' +test_expect_success 'rev-list --missing=allow-promisor on partial clone' ' + git -C pc1 rev-list --objects --missing=allow-promisor HEAD >actual && + git -C pc1 rev-list --objects --missing=print HEAD >expect.raw && + grep -v "^?" expect.raw >expect && + test_cmp expect actual +' + test_expect_success 'verify that .promisor file contains refs fetched' ' ls pc1/.git/objects/pack/pack-*.promisor >promisorlist && test_line_count = 1 promisorlist && @@ -72,9 +79,9 @@ test_expect_success 'push new commits to server' ' git -C src remote add srv "file://$(pwd)/srv.bare" && for x in a b c d e do - echo "Mod file.1.txt $x" >>src/file.1.txt - git -C src add file.1.txt - git -C src commit -m "mod $x" + echo "Mod file.1.txt $x" >>src/file.1.txt && + git -C src add file.1.txt && + git -C src commit -m "mod $x" || return 1 done && git -C src blame main -- file.1.txt >expect.blame && git -C src push -u srv main @@ -114,9 +121,9 @@ test_expect_success 'verify blame causes dynamic object fetch' ' test_expect_success 'push new commits to server for file.2.txt' ' for x in a b c d e f do - echo "Mod file.2.txt $x" >>src/file.2.txt - git -C src add file.2.txt - git -C src commit -m "mod $x" + echo "Mod file.2.txt $x" >>src/file.2.txt && + git -C src add file.2.txt && + git -C src commit -m "mod $x" || return 1 done && git -C src push -u srv main ' @@ -135,9 +142,9 @@ test_expect_success 'override inherited filter-spec using --no-filter' ' test_expect_success 'push new commits to server for file.3.txt' ' for x in a b c d e f do - echo "Mod file.3.txt $x" >>src/file.3.txt - git -C src add file.3.txt - git -C src commit -m "mod $x" + echo "Mod file.3.txt $x" >>src/file.3.txt && + git -C src add file.3.txt && + git -C src commit -m "mod $x" || return 1 done && git -C src push -u srv main ' @@ -166,13 +173,94 @@ test_expect_success 'manual prefetch of missing objects' ' test_line_count = 0 observed.oids ' +# create new commits in "src" repo to establish a history on file.4.txt +# and push to "srv.bare". +test_expect_success 'push new commits to server for file.4.txt' ' + for x in a b c d e f + do + echo "Mod file.4.txt $x" >src/file.4.txt && + if list_contains "a,b" "$x"; then + printf "%10000s" X >>src/file.4.txt + fi && + if list_contains "c,d" "$x"; then + printf "%20000s" X >>src/file.4.txt + fi && + git -C src add file.4.txt && + git -C src commit -m "mod $x" || return 1 + done && + git -C src push -u srv main +' + +# Do partial fetch to fetch smaller files; then verify that without --refetch +# applying a new filter does not refetch missing large objects. Then use +# --refetch to apply the new filter on existing commits. Test it under both +# protocol v2 & v0. +test_expect_success 'apply a different filter using --refetch' ' + git -C pc1 fetch --filter=blob:limit=999 origin && + git -C pc1 rev-list --quiet --objects --missing=print \ + main..origin/main >observed && + test_line_count = 4 observed && + + git -C pc1 fetch --filter=blob:limit=19999 --refetch origin && + git -C pc1 rev-list --quiet --objects --missing=print \ + main..origin/main >observed && + test_line_count = 2 observed && + + git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 \ + --refetch origin && + git -C pc1 rev-list --quiet --objects --missing=print \ + main..origin/main >observed && + test_line_count = 0 observed +' + +test_expect_success 'fetch --refetch works with a shallow clone' ' + git clone --no-checkout --depth=1 --filter=blob:none "file://$(pwd)/srv.bare" pc1s && + git -C pc1s rev-list --objects --missing=print HEAD >observed && + test_line_count = 6 observed && + + GIT_TRACE=1 git -C pc1s fetch --filter=blob:limit=999 --refetch origin && + git -C pc1s rev-list --objects --missing=print HEAD >observed && + test_line_count = 6 observed +' + +test_expect_success 'fetch --refetch triggers repacking' ' + GIT_TRACE2_CONFIG_PARAMS=gc.autoPackLimit,maintenance.incremental-repack.auto && + export GIT_TRACE2_CONFIG_PARAMS && + + GIT_TRACE2_EVENT="$PWD/trace1.event" \ + git -C pc1 fetch --refetch origin && + test_subcommand git maintenance run --auto --no-quiet <trace1.event && + grep \"param\":\"gc.autopacklimit\",\"value\":\"1\" trace1.event && + grep \"param\":\"maintenance.incremental-repack.auto\",\"value\":\"-1\" trace1.event && + + GIT_TRACE2_EVENT="$PWD/trace2.event" \ + git -c protocol.version=0 \ + -c gc.autoPackLimit=0 \ + -c maintenance.incremental-repack.auto=1234 \ + -C pc1 fetch --refetch origin && + test_subcommand git maintenance run --auto --no-quiet <trace2.event && + grep \"param\":\"gc.autopacklimit\",\"value\":\"0\" trace2.event && + grep \"param\":\"maintenance.incremental-repack.auto\",\"value\":\"-1\" trace2.event && + + GIT_TRACE2_EVENT="$PWD/trace3.event" \ + git -c protocol.version=0 \ + -c gc.autoPackLimit=1234 \ + -c maintenance.incremental-repack.auto=0 \ + -C pc1 fetch --refetch origin && + test_subcommand git maintenance run --auto --no-quiet <trace3.event && + grep \"param\":\"gc.autopacklimit\",\"value\":\"1\" trace3.event && + grep \"param\":\"maintenance.incremental-repack.auto\",\"value\":\"0\" trace3.event +' + test_expect_success 'partial clone with transfer.fsckobjects=1 works with submodules' ' test_create_repo submodule && test_commit -C submodule mycommit && test_create_repo src_with_sub && - test_config -C src_with_sub uploadpack.allowfilter 1 && - test_config -C src_with_sub uploadpack.allowanysha1inwant 1 && + git -C src_with_sub config uploadpack.allowfilter 1 && + git -C src_with_sub config uploadpack.allowanysha1inwant 1 && + + test_config_global protocol.file.allow always && git -C src_with_sub submodule add "file://$(pwd)/submodule" mysub && git -C src_with_sub commit -m "commit with submodule" && @@ -182,6 +270,12 @@ test_expect_success 'partial clone with transfer.fsckobjects=1 works with submod test_when_finished rm -rf dst ' +test_expect_success 'lazily fetched .gitmodules works' ' + git clone --filter="blob:none" --no-checkout "file://$(pwd)/src_with_sub" dst && + git -C dst fetch && + test_when_finished rm -rf dst +' + test_expect_success 'partial clone with transfer.fsckobjects=1 uses index-pack --fsck-objects' ' git init src && test_commit -C src x && @@ -225,7 +319,7 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr # Auto-fetch all remaining trees and blobs with --missing=error git -C dst rev-list --missing=error --objects main >fetched_objects && - test_line_count = 70 fetched_objects && + test_line_count = 88 fetched_objects && awk -f print_1.awk fetched_objects | xargs -n1 git -C dst cat-file -t >fetched_types && @@ -259,14 +353,14 @@ test_expect_success 'upload-pack complains of bogus filter config' ' test_must_fail git \ -c uploadpackfilter.tree.maxdepth \ upload-pack . >/dev/null 2>err && - test_i18ngrep "unable to parse.*tree.maxdepth" err + test_grep "unable to parse.*tree.maxdepth" err ' test_expect_success 'upload-pack fails banned object filters' ' test_config -C srv.bare uploadpackfilter.blob:none.allow false && test_must_fail ok=sigpipe git clone --no-checkout --filter=blob:none \ "file://$(pwd)/srv.bare" pc3 2>err && - test_i18ngrep "filter '\''blob:none'\'' not supported" err + test_grep "filter '\''blob:none'\'' not supported" err ' test_expect_success 'upload-pack fails banned combine object filters' ' @@ -276,14 +370,14 @@ test_expect_success 'upload-pack fails banned combine object filters' ' test_config -C srv.bare uploadpackfilter.blob:none.allow false && test_must_fail ok=sigpipe git clone --no-checkout --filter=tree:1 \ --filter=blob:none "file://$(pwd)/srv.bare" pc3 2>err && - test_i18ngrep "filter '\''blob:none'\'' not supported" err + test_grep "filter '\''blob:none'\'' not supported" err ' test_expect_success 'upload-pack fails banned object filters with fallback' ' test_config -C srv.bare uploadpackfilter.allow false && test_must_fail ok=sigpipe git clone --no-checkout --filter=blob:none \ "file://$(pwd)/srv.bare" pc3 2>err && - test_i18ngrep "filter '\''blob:none'\'' not supported" err + test_grep "filter '\''blob:none'\'' not supported" err ' test_expect_success 'upload-pack limits tree depth filters' ' @@ -292,7 +386,7 @@ test_expect_success 'upload-pack limits tree depth filters' ' test_config -C srv.bare uploadpackfilter.tree.maxDepth 0 && test_must_fail ok=sigpipe git clone --no-checkout --filter=tree:1 \ "file://$(pwd)/srv.bare" pc3 2>err && - test_i18ngrep "tree filter allows max depth 0, but got 1" err && + test_grep "tree filter allows max depth 0, but got 1" err && git clone --no-checkout --filter=tree:0 "file://$(pwd)/srv.bare" pc4 && @@ -300,7 +394,7 @@ test_expect_success 'upload-pack limits tree depth filters' ' git clone --no-checkout --filter=tree:5 "file://$(pwd)/srv.bare" pc5 && test_must_fail ok=sigpipe git clone --no-checkout --filter=tree:6 \ "file://$(pwd)/srv.bare" pc6 2>err && - test_i18ngrep "tree filter allows max depth 5, but got 6" err + test_grep "tree filter allows max depth 5, but got 6" err ' test_expect_success 'partial clone fetches blobs pointed to by refs even if normally filtered out' ' @@ -365,11 +459,11 @@ test_expect_success 'partial clone with unresolvable sparse filter fails cleanly test_must_fail git clone --no-local --bare \ --filter=sparse:oid=main:no-such-name \ sparse-src dst.git 2>err && - test_i18ngrep "unable to access sparse blob in .main:no-such-name" err && + test_grep "unable to access sparse blob in .main:no-such-name" err && test_must_fail git clone --no-local --bare \ --filter=sparse:oid=main \ sparse-src dst.git 2>err && - test_i18ngrep "unable to parse sparse filter data in" err + test_grep "unable to parse sparse filter data in" err ' setup_triangle () { @@ -385,7 +479,7 @@ setup_triangle () { for i in $(test_seq 1 100) do echo "make the tree big" >server/file$i && - git -C server add file$i + git -C server add file$i || return 1 done && git -C server commit -m "initial" && git clone --bare --filter=tree:0 "file://$(pwd)/server" client && @@ -399,8 +493,8 @@ setup_triangle () { TREE_HASH=$(git -C server rev-parse HEAD~1^{tree}) && git -C promisor-remote fetch --keep "file://$(pwd)/server" "$TREE_HASH" && git -C promisor-remote count-objects -v >object-count && - test_i18ngrep "count: 0" object-count && - test_i18ngrep "in-pack: 2" object-count && + test_grep "count: 0" object-count && + test_grep "in-pack: 2" object-count && # Set it as the promisor remote of client. Thus, whenever # the client lazy fetches, the lazy fetch will succeed only if it is @@ -556,6 +650,49 @@ test_expect_success 'repack does not loosen promisor objects' ' grep "loosen_unused_packed_objects/loosened:0" trace ' +test_expect_success 'lazy-fetch in submodule succeeds' ' + # setup + test_config_global protocol.file.allow always && + + test_when_finished "rm -rf src-sub" && + git init src-sub && + git -C src-sub config uploadpack.allowfilter 1 && + git -C src-sub config uploadpack.allowanysha1inwant 1 && + + # This blob must be missing in the subsequent commit. + echo foo >src-sub/file && + git -C src-sub add file && + git -C src-sub commit -m "submodule one" && + SUB_ONE=$(git -C src-sub rev-parse HEAD) && + + echo bar >src-sub/file && + git -C src-sub add file && + git -C src-sub commit -m "submodule two" && + SUB_TWO=$(git -C src-sub rev-parse HEAD) && + + test_when_finished "rm -rf src-super" && + git init src-super && + git -C src-super config uploadpack.allowfilter 1 && + git -C src-super config uploadpack.allowanysha1inwant 1 && + git -C src-super submodule add ../src-sub src-sub && + + git -C src-super/src-sub checkout $SUB_ONE && + git -C src-super add src-sub && + git -C src-super commit -m "superproject one" && + + git -C src-super/src-sub checkout $SUB_TWO && + git -C src-super add src-sub && + git -C src-super commit -m "superproject two" && + + # the fetch + test_when_finished "rm -rf client" && + git clone --filter=blob:none --also-filter-submodules \ + --recurse-submodules "file://$(pwd)/src-super" client && + + # Trigger lazy-fetch from the superproject + git -C client restore --recurse-submodules --source=HEAD^ :/ +' + . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -611,7 +748,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' ' test_must_fail git -c protocol.version=2 clone \ --filter=blob:none $HTTPD_URL/one_time_perl/server repo 2>err && - test_i18ngrep "did not send all necessary objects" err && + test_grep "did not send all necessary objects" err && # Ensure that the one-time-perl script was used. ! test -e "$HTTPD_ROOT_PATH/one-time-perl" @@ -669,7 +806,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor for i in $(test_seq 10) do echo "this is a line" >>"$SERVER/foo.txt" && - echo "this is another line" >>"$SERVER/have.txt" + echo "this is another line" >>"$SERVER/have.txt" || return 1 done && git -C "$SERVER" add foo.txt have.txt && git -C "$SERVER" commit -m bar && |