tests: always test fetch of unreachable with v0

Some tests check that fetching an unreachable object fails, but protocol v2 allows such fetches. Unset GIT_TEST_PROTOCOL_VERSION so that these tests are always run using protocol v0. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Feb 25, 2019 at 13:54 UTC ab0c5f5096be62c2c964549673bc8965b2ddfb0e
4 files changed +32 -9
t/t5500-fetch-pack.sh
+3 -1
@@ -636,7 +636,9 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a
636 test_commit -C server 6 &&
637
638 git init client &&
639 - test_must_fail git -C client fetch-pack ../server \
639 + # Some protocol versions (e.g. 2) support fetching
640 + # unadvertised objects, so restrict this test to v0.
641 + test_must_fail env GIT_TEST_PROTOCOL_VERSION= git -C client fetch-pack ../server \
642 $(git -C server rev-parse refs/heads/master^) 2>err &&
643 test_i18ngrep "Server does not allow request for unadvertised object" err
644 '
t/t5516-fetch-push.sh
+17 -5
@@ -1147,8 +1147,12 @@ test_expect_success 'fetch exact SHA1' '
1147 git prune &&
1148 test_must_fail git cat-file -t $the_commit &&
1149
1150 + # Some protocol versions (e.g. 2) support fetching
1151 + # unadvertised objects, so restrict this test to v0.
1152 +
1153 # fetching the hidden object should fail by default
1151 - test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
1154 + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1155 + git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
1156 test_i18ngrep "Server does not allow request for unadvertised object" err &&
1157 test_must_fail git rev-parse --verify refs/heads/copy &&
1158
@@ -1204,7 +1208,10 @@ do
1208 mk_empty shallow &&
1209 (
1210 cd shallow &&
1207 - test_must_fail git fetch --depth=1 ../testrepo/.git $SHA1 &&
1211 + # Some protocol versions (e.g. 2) support fetching
1212 + # unadvertised objects, so restrict this test to v0.
1213 + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1214 + git fetch --depth=1 ../testrepo/.git $SHA1 &&
1215 git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
1216 git fetch --depth=1 ../testrepo/.git $SHA1 &&
1217 git cat-file commit $SHA1
@@ -1232,15 +1239,20 @@ do
1239 mk_empty shallow &&
1240 (
1241 cd shallow &&
1235 - test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3 &&
1236 - test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_1 &&
1242 + # Some protocol versions (e.g. 2) support fetching
1243 + # unadvertised objects, so restrict this test to v0.
1244 + test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
1245 + git fetch ../testrepo/.git $SHA1_3 &&
1246 + test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
1247 + git fetch ../testrepo/.git $SHA1_1 &&
1248 git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
1249 git fetch ../testrepo/.git $SHA1_1 &&
1250 git cat-file commit $SHA1_1 &&
1251 test_must_fail git cat-file commit $SHA1_2 &&
1252 git fetch ../testrepo/.git $SHA1_2 &&
1253 git cat-file commit $SHA1_2 &&
1243 - test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3
1254 + test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
1255 + git fetch ../testrepo/.git $SHA1_3
1256 )
1257 '
1258 done
t/t5551-http-fetch-smart.sh
+8 -2
@@ -307,7 +307,10 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' '
307
308 git init --bare test_reachable.git &&
309 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
310 - test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
310 + # Some protocol versions (e.g. 2) support fetching
311 + # unadvertised objects, so restrict this test to v0.
312 + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
313 + git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
314 '
315
316 test_expect_success 'test allowanysha1inwant with unreachable' '
@@ -326,7 +329,10 @@ test_expect_success 'test allowanysha1inwant with unreachable' '
329
330 git init --bare test_reachable.git &&
331 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
329 - test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
332 + # Some protocol versions (e.g. 2) support fetching
333 + # unadvertised objects, so restrict this test to v0.
334 + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
335 + git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
336
337 git -C "$server" config uploadpack.allowanysha1inwant 1 &&
338 git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
t/t7406-submodule-update.sh
+4 -1
@@ -943,7 +943,10 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
943 cd super3 &&
944 sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
945 mv -f .gitmodules.tmp .gitmodules &&
946 - test_must_fail git submodule update --init --depth=1 2>actual &&
946 + # Some protocol versions (e.g. 2) support fetching
947 + # unadvertised objects, so restrict this test to v0.
948 + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
949 + git submodule update --init --depth=1 2>actual &&
950 test_i18ngrep "Direct fetching of that commit failed." actual &&
951 git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
952 git submodule update --init --depth=1 >actual &&