]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: always test fetch of unreachable with v0
authorJonathan Tan <jonathantanmy@google.com>
Mon, 25 Feb 2019 21:54:08 +0000 (13:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Mar 2019 01:02:42 +0000 (10:02 +0900)
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>
t/t5500-fetch-pack.sh
t/t5516-fetch-push.sh
t/t5551-http-fetch-smart.sh
t/t7406-submodule-update.sh

index 49c540b1e1dbd5fc7d9a7baa36ee93a2ed3fc3c3..0ef4d6f20c226d544daa4ea62adf19e4ec946ce4 100755 (executable)
@@ -636,7 +636,9 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a
        test_commit -C server 6 &&
 
        git init client &&
-       test_must_fail git -C client fetch-pack ../server \
+       # Some protocol versions (e.g. 2) support fetching
+       # unadvertised objects, so restrict this test to v0.
+       test_must_fail env GIT_TEST_PROTOCOL_VERSION= git -C client fetch-pack ../server \
                $(git -C server rev-parse refs/heads/master^) 2>err &&
        test_i18ngrep "Server does not allow request for unadvertised object" err
 '
index 37e8e80893dad130c5c00882796047417aae115b..4bfbb7965476991e41c042b47e74ef9c6187efcc 100755 (executable)
@@ -1147,8 +1147,12 @@ test_expect_success 'fetch exact SHA1' '
                git prune &&
                test_must_fail git cat-file -t $the_commit &&
 
+               # Some protocol versions (e.g. 2) support fetching
+               # unadvertised objects, so restrict this test to v0.
+
                # fetching the hidden object should fail by default
-               test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
+               test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
+                       git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
                test_i18ngrep "Server does not allow request for unadvertised object" err &&
                test_must_fail git rev-parse --verify refs/heads/copy &&
 
@@ -1204,7 +1208,10 @@ do
                mk_empty shallow &&
                (
                        cd shallow &&
-                       test_must_fail git fetch --depth=1 ../testrepo/.git $SHA1 &&
+                       # Some protocol versions (e.g. 2) support fetching
+                       # unadvertised objects, so restrict this test to v0.
+                       test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
+                               git fetch --depth=1 ../testrepo/.git $SHA1 &&
                        git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
                        git fetch --depth=1 ../testrepo/.git $SHA1 &&
                        git cat-file commit $SHA1
@@ -1232,15 +1239,20 @@ do
                mk_empty shallow &&
                (
                        cd shallow &&
-                       test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3 &&
-                       test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_1 &&
+                       # Some protocol versions (e.g. 2) support fetching
+                       # unadvertised objects, so restrict this test to v0.
+                       test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
+                               git fetch ../testrepo/.git $SHA1_3 &&
+                       test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
+                               git fetch ../testrepo/.git $SHA1_1 &&
                        git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
                        git fetch ../testrepo/.git $SHA1_1 &&
                        git cat-file commit $SHA1_1 &&
                        test_must_fail git cat-file commit $SHA1_2 &&
                        git fetch ../testrepo/.git $SHA1_2 &&
                        git cat-file commit $SHA1_2 &&
-                       test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3
+                       test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
+                               git fetch ../testrepo/.git $SHA1_3
                )
        '
 done
index f7a84f30035009f945d6739b2075c06e3ca15c61..04a9939b36a5dde50e9f02dd9bb4373bab77115f 100755 (executable)
@@ -307,7 +307,10 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' '
 
        git init --bare test_reachable.git &&
        git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
-       test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
+       # Some protocol versions (e.g. 2) support fetching
+       # unadvertised objects, so restrict this test to v0.
+       test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
+               git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
 '
 
 test_expect_success 'test allowanysha1inwant with unreachable' '
@@ -326,7 +329,10 @@ test_expect_success 'test allowanysha1inwant with unreachable' '
 
        git init --bare test_reachable.git &&
        git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
-       test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
+       # Some protocol versions (e.g. 2) support fetching
+       # unadvertised objects, so restrict this test to v0.
+       test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
+               git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
 
        git -C "$server" config uploadpack.allowanysha1inwant 1 &&
        git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
index e87164aa8ffdba169ba6f91af99ae3d28f28459b..c973278300a5c911845016ef1e23144f51ebcd7d 100755 (executable)
@@ -943,7 +943,10 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
                cd super3 &&
                sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
                mv -f .gitmodules.tmp .gitmodules &&
-               test_must_fail git submodule update --init --depth=1 2>actual &&
+               # Some protocol versions (e.g. 2) support fetching
+               # unadvertised objects, so restrict this test to v0.
+               test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
+                       git submodule update --init --depth=1 2>actual &&
                test_i18ngrep "Direct fetching of that commit failed." actual &&
                git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
                git submodule update --init --depth=1 >actual &&