Skip to content

Commit 07ef3c6

Browse files
jrngitster
authored andcommitted
fetch test: use more robust test for filtered objects
"git cat-file -e" uses has_object_file, which can fetch from promisor remotes when an object is missing. These tests end up checking that that fetch fails instead of for the object being missing. By luck, the tests pass anyway: - in one of these tests ("filtering by size"), the fetch fails because (in protocol v0) the server does not support fetches by SHA-1 - in the second, the object is present but the test could pass even if it weren't if the fetch succeeds - in the third, the test sets extensions.partialClone to "arbitrary string" so that when it tries to fetch, it looks up the "arbitrary string" remote which does not exist Use "git rev-list --objects --missing=allow-any", so that the tests pass for the right reason. Noticed while testing with protocol v2, which allows fetching by sha1 by default, causing the first fetch to succeed and the test to fail. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d6509da commit 07ef3c6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

t/t5500-fetch-pack.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,10 @@ test_expect_success 'filtering by size' '
917917
git -C client fetch-pack --filter=blob:limit=0 ../server HEAD &&
918918
919919
# Ensure that object is not inadvertently fetched
920-
test_must_fail git -C client cat-file -e $(git hash-object server/one.t)
920+
commit=$(git -C server rev-parse HEAD) &&
921+
blob=$(git hash-object server/one.t) &&
922+
git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
923+
! grep "$blob" oids
921924
'
922925

923926
test_expect_success 'filtering by size has no effect if support for it is not advertised' '
@@ -929,7 +932,10 @@ test_expect_success 'filtering by size has no effect if support for it is not ad
929932
git -C client fetch-pack --filter=blob:limit=0 ../server HEAD 2> err &&
930933
931934
# Ensure that object is fetched
932-
git -C client cat-file -e $(git hash-object server/one.t) &&
935+
commit=$(git -C server rev-parse HEAD) &&
936+
blob=$(git hash-object server/one.t) &&
937+
git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
938+
grep "$blob" oids &&
933939
934940
test_i18ngrep "filtering not recognized by server" err
935941
'
@@ -951,9 +957,11 @@ fetch_filter_blob_limit_zero () {
951957
git -C client fetch --filter=blob:limit=0 origin HEAD:somewhere &&
952958

953959
# Ensure that commit is fetched, but blob is not
954-
test_config -C client extensions.partialclone "arbitrary string" &&
955-
git -C client cat-file -e $(git -C "$SERVER" rev-parse two) &&
956-
test_must_fail git -C client cat-file -e $(git hash-object "$SERVER/two.t")
960+
commit=$(git -C "$SERVER" rev-parse two) &&
961+
blob=$(git hash-object server/two.t) &&
962+
git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
963+
grep "$commit" oids &&
964+
! grep "$blob" oids
957965
}
958966

959967
test_expect_success 'fetch with --filter=blob:limit=0' '

0 commit comments

Comments
 (0)