@matheusbsbs / matheus-bagliano / commits / 8a1b0978ab
Fork 0

test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate

Since 8cbeba0632 (tests: define GIT_TEST_PROTOCOL_VERSION, 2019-02-25), it has been possible to run tests with a newer protocol version by setting the GIT_TEST_PROTOCOL_VERSION envvar to a version number. Tests that assume protocol v0 handle this by explicitly setting GIT_TEST_PROTOCOL_VERSION= or similar constructs like 'test -z "$GIT_TEST_PROTOCOL_VERSION" || return 0' to declare that they only handle the default (v0) protocol. The emphasis there is a bit off: it would be clearer to specify GIT_TEST_PROTOCOL_VERSION=0 to inform the reader that these tests are specifically testing and relying on details of protocol v0. Do so. This way, a reader does not need to know what the default protocol version is, and the tests can continue to work when the default protocol version used by Git advances past v0. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Dec 23, 2019 at 17:01 UTC 8a1b0978abf8b3fb0ee2dc7a7d71766ed0ef4768
11 files changed +30 -27
t/t5400-send-pack.sh
+1 -1
@@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' '
288 $shared .have
289 EOF
290
291 - GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \
291 + GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION=0 \
292 git push \
293 --receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
294 fork HEAD:foo &&
t/t5500-fetch-pack.sh
+3 -2
@@ -440,11 +440,12 @@ test_expect_success 'setup tests for the --stdin parameter' '
440 '
441
442 test_expect_success 'setup fetch refs from cmdline v[12]' '
443 + cp -r client client0 &&
444 cp -r client client1 &&
445 cp -r client client2
446 '
447
447 -for version in '' 1 2
448 +for version in '' 0 1 2
449 do
450 test_expect_success "protocol.version=$version fetch refs from cmdline" "
451 (
@@ -638,7 +639,7 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a
639 git init client &&
640 # Some protocol versions (e.g. 2) support fetching
641 # unadvertised objects, so restrict this test to v0.
641 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= git -C client fetch-pack ../server \
642 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C client fetch-pack ../server \
643 $(git -C server rev-parse refs/heads/master^) 2>err &&
644 test_i18ngrep "Server does not allow request for unadvertised object" err
645 '
t/t5512-ls-remote.sh
+5 -5
@@ -225,7 +225,7 @@ test_expect_success 'ls-remote --symref' '
225 EOF
226 # Protocol v2 supports sending symrefs for refs other than HEAD, so use
227 # protocol v0 here.
228 - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref >actual &&
228 + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
229 test_cmp expect actual
230 '
231
@@ -236,7 +236,7 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
236 EOF
237 # Protocol v2 supports sending symrefs for refs other than HEAD, so use
238 # protocol v0 here.
239 - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . HEAD >actual &&
239 + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . HEAD >actual &&
240 test_cmp expect actual
241 '
242
@@ -249,7 +249,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' '
249 EOF
250 # Protocol v2 supports sending symrefs for refs other than HEAD, so use
251 # protocol v0 here.
252 - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual &&
252 + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
253 test_cmp expect actual
254 '
255
@@ -260,9 +260,9 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
260 EOF
261 # Protocol v2 supports sending symrefs for refs other than HEAD, so use
262 # protocol v0 here.
263 - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual &&
263 + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
264 test_cmp expect actual &&
265 - GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . "refs/heads/*" >actual &&
265 + GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . "refs/heads/*" >actual &&
266 test_cmp expect actual
267 '
268
t/t5515-fetch-merge-logic.sh
+2 -1
@@ -8,7 +8,8 @@ test_description='Merge logic in fetch'
8
9 # NEEDSWORK: If the overspecification of the expected result is reduced, we
10 # might be able to run this test in all protocol versions.
11 -GIT_TEST_PROTOCOL_VERSION=
11 +GIT_TEST_PROTOCOL_VERSION=0
12 +export GIT_TEST_PROTOCOL_VERSION
13
14 . ./test-lib.sh
15
t/t5516-fetch-push.sh
+6 -6
@@ -1151,7 +1151,7 @@ test_expect_success 'fetch exact SHA1' '
1151 # unadvertised objects, so restrict this test to v0.
1152
1153 # fetching the hidden object should fail by default
1154 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1154 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
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 &&
@@ -1210,7 +1210,7 @@ do
1210 cd shallow &&
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= \
1213 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
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 &&
@@ -1241,9 +1241,9 @@ do
1241 cd shallow &&
1242 # Some protocol versions (e.g. 2) support fetching
1243 # unadvertised objects, so restrict this test to v0.
1244 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1244 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
1245 git fetch ../testrepo/.git $SHA1_3 &&
1246 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1246 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
1247 git fetch ../testrepo/.git $SHA1_1 &&
1248 git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
1249 git fetch ../testrepo/.git $SHA1_1 &&
@@ -1251,7 +1251,7 @@ do
1251 test_must_fail git cat-file commit $SHA1_2 &&
1252 git fetch ../testrepo/.git $SHA1_2 &&
1253 git cat-file commit $SHA1_2 &&
1254 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1254 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
1255 git fetch ../testrepo/.git $SHA1_3 2>err &&
1256 test_i18ngrep "remote error:.*not our ref.*$SHA1_3\$" err
1257 )
@@ -1291,7 +1291,7 @@ test_expect_success 'peeled advertisements are not considered ref tips' '
1291 git -C testrepo commit --allow-empty -m two &&
1292 git -C testrepo tag -m foo mytag HEAD^ &&
1293 oid=$(git -C testrepo rev-parse mytag^{commit}) &&
1294 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
1294 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
1295 git fetch testrepo $oid 2>err &&
1296 test_i18ngrep "Server does not allow request for unadvertised object" err
1297 '
t/t5539-fetch-http-shallow.sh
+1 -1
@@ -69,7 +69,7 @@ test_expect_success 'no shallow lines after receiving ACK ready' '
69 test_commit new-too &&
70 # NEEDSWORK: If the overspecification of the expected result is reduced, we
71 # might be able to run this test in all protocol versions.
72 - GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION= \
72 + GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \
73 git fetch --depth=2 &&
74 grep "fetch-pack< ACK .* ready" ../trace &&
75 ! grep "fetch-pack> done" ../trace
t/t5541-http-push-smart.sh
+2 -2
@@ -49,7 +49,7 @@ test_expect_success 'no empty path components' '
49
50 # NEEDSWORK: If the overspecification of the expected result is reduced, we
51 # might be able to run this test in all protocol versions.
52 - if test -z "$GIT_TEST_PROTOCOL_VERSION"
52 + if test "$GIT_TEST_PROTOCOL_VERSION" = 0
53 then
54 check_access_log exp
55 fi
@@ -135,7 +135,7 @@ EOF
135 test_expect_success 'used receive-pack service' '
136 # NEEDSWORK: If the overspecification of the expected result is reduced, we
137 # might be able to run this test in all protocol versions.
138 - if test -z "$GIT_TEST_PROTOCOL_VERSION"
138 + if test "$GIT_TEST_PROTOCOL_VERSION" = 0
139 then
140 check_access_log exp
141 fi
t/t5551-http-fetch-smart.sh
+6 -6
@@ -43,7 +43,7 @@ test_expect_success 'clone http repository' '
43 < Cache-Control: no-cache, max-age=0, must-revalidate
44 < Content-Type: application/x-git-upload-pack-result
45 EOF
46 - GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \
46 + GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 \
47 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
48 test_cmp file clone/file &&
49 tr '\''\015'\'' Q <err |
@@ -84,7 +84,7 @@ test_expect_success 'clone http repository' '
84
85 # NEEDSWORK: If the overspecification of the expected result is reduced, we
86 # might be able to run this test in all protocol versions.
87 - if test -z "$GIT_TEST_PROTOCOL_VERSION"
87 + if test "$GIT_TEST_PROTOCOL_VERSION" = 0
88 then
89 sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
90 actual >actual.smudged &&
@@ -113,7 +113,7 @@ test_expect_success 'used upload-pack service' '
113
114 # NEEDSWORK: If the overspecification of the expected result is reduced, we
115 # might be able to run this test in all protocol versions.
116 - if test -z "$GIT_TEST_PROTOCOL_VERSION"
116 + if test "$GIT_TEST_PROTOCOL_VERSION" = 0
117 then
118 check_access_log exp
119 fi
@@ -241,7 +241,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
241
242 # NEEDSWORK: If the overspecification of the expected result is reduced, we
243 # might be able to run this test in all protocol versions.
244 - if test -z "$GIT_TEST_PROTOCOL_VERSION"
244 + if test "$GIT_TEST_PROTOCOL_VERSION" = 0
245 then
246 tail -3 cookies.txt | sort >cookies_tail.txt &&
247 test_cmp expect_cookies.txt cookies_tail.txt
@@ -336,7 +336,7 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' '
336 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
337 # Some protocol versions (e.g. 2) support fetching
338 # unadvertised objects, so restrict this test to v0.
339 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
339 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
340 git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
341 '
342
@@ -358,7 +358,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' '
358 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
359 # Some protocol versions (e.g. 2) support fetching
360 # unadvertised objects, so restrict this test to v0.
361 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
361 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
362 git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
363
364 git -C "$server" config uploadpack.allowanysha1inwant 1 &&
t/t5552-skipping-fetch-negotiator.sh
+1 -1
@@ -108,7 +108,7 @@ test_expect_success 'use ref advertisement to filter out commits' '
108 # The ref advertisement itself is filtered when protocol v2 is used, so
109 # use v0.
110 (
111 - GIT_TEST_PROTOCOL_VERSION= &&
111 + GIT_TEST_PROTOCOL_VERSION=0 &&
112 export GIT_TEST_PROTOCOL_VERSION &&
113 trace_fetch client origin to_fetch
114 ) &&
t/t5700-protocol-v1.sh
+2 -1
@@ -5,7 +5,8 @@ test_description='test git wire-protocol transition'
5 TEST_NO_CREATE_REPO=1
6
7 # This is a protocol-specific test.
8 -GIT_TEST_PROTOCOL_VERSION=
8 +GIT_TEST_PROTOCOL_VERSION=0
9 +export GIT_TEST_PROTOCOL_VERSION
10
11 . ./test-lib.sh
12
t/t7406-submodule-update.sh
+1 -1
@@ -960,7 +960,7 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
960 mv -f .gitmodules.tmp .gitmodules &&
961 # Some protocol versions (e.g. 2) support fetching
962 # unadvertised objects, so restrict this test to v0.
963 - test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
963 + test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
964 git submodule update --init --depth=1 2>actual &&
965 test_i18ngrep "Direct fetching of that commit failed." actual &&
966 git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&