Skip to content

Commit 8a1b097

Browse files
jrngitster
authored andcommitted
test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate
Since 8cbeba0 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b9ab170 commit 8a1b097

11 files changed

+30
-27
lines changed

t/t5400-send-pack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' '
288288
$shared .have
289289
EOF
290290
291-
GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \
291+
GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION=0 \
292292
git push \
293293
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
294294
fork HEAD:foo &&

t/t5500-fetch-pack.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,12 @@ test_expect_success 'setup tests for the --stdin parameter' '
440440
'
441441

442442
test_expect_success 'setup fetch refs from cmdline v[12]' '
443+
cp -r client client0 &&
443444
cp -r client client1 &&
444445
cp -r client client2
445446
'
446447

447-
for version in '' 1 2
448+
for version in '' 0 1 2
448449
do
449450
test_expect_success "protocol.version=$version fetch refs from cmdline" "
450451
(
@@ -638,7 +639,7 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a
638639
git init client &&
639640
# Some protocol versions (e.g. 2) support fetching
640641
# 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 \
642643
$(git -C server rev-parse refs/heads/master^) 2>err &&
643644
test_i18ngrep "Server does not allow request for unadvertised object" err
644645
'

t/t5512-ls-remote.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ test_expect_success 'ls-remote --symref' '
225225
EOF
226226
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
227227
# protocol v0 here.
228-
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref >actual &&
228+
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
229229
test_cmp expect actual
230230
'
231231

@@ -236,7 +236,7 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
236236
EOF
237237
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
238238
# 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 &&
240240
test_cmp expect actual
241241
'
242242

@@ -249,7 +249,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' '
249249
EOF
250250
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
251251
# 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 &&
253253
test_cmp expect actual
254254
'
255255

@@ -260,9 +260,9 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
260260
EOF
261261
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
262262
# 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 &&
264264
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 &&
266266
test_cmp expect actual
267267
'
268268

t/t5515-fetch-merge-logic.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ test_description='Merge logic in fetch'
88

99
# NEEDSWORK: If the overspecification of the expected result is reduced, we
1010
# 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
1213

1314
. ./test-lib.sh
1415

t/t5516-fetch-push.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ test_expect_success 'fetch exact SHA1' '
11511151
# unadvertised objects, so restrict this test to v0.
11521152
11531153
# 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 \
11551155
git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
11561156
test_i18ngrep "Server does not allow request for unadvertised object" err &&
11571157
test_must_fail git rev-parse --verify refs/heads/copy &&
@@ -1210,7 +1210,7 @@ do
12101210
cd shallow &&
12111211
# Some protocol versions (e.g. 2) support fetching
12121212
# 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 \
12141214
git fetch --depth=1 ../testrepo/.git $SHA1 &&
12151215
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
12161216
git fetch --depth=1 ../testrepo/.git $SHA1 &&
@@ -1241,17 +1241,17 @@ do
12411241
cd shallow &&
12421242
# Some protocol versions (e.g. 2) support fetching
12431243
# 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 \
12451245
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 \
12471247
git fetch ../testrepo/.git $SHA1_1 &&
12481248
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
12491249
git fetch ../testrepo/.git $SHA1_1 &&
12501250
git cat-file commit $SHA1_1 &&
12511251
test_must_fail git cat-file commit $SHA1_2 &&
12521252
git fetch ../testrepo/.git $SHA1_2 &&
12531253
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 \
12551255
git fetch ../testrepo/.git $SHA1_3 2>err &&
12561256
test_i18ngrep "remote error:.*not our ref.*$SHA1_3\$" err
12571257
)
@@ -1291,7 +1291,7 @@ test_expect_success 'peeled advertisements are not considered ref tips' '
12911291
git -C testrepo commit --allow-empty -m two &&
12921292
git -C testrepo tag -m foo mytag HEAD^ &&
12931293
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 \
12951295
git fetch testrepo $oid 2>err &&
12961296
test_i18ngrep "Server does not allow request for unadvertised object" err
12971297
'

t/t5539-fetch-http-shallow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test_expect_success 'no shallow lines after receiving ACK ready' '
6969
test_commit new-too &&
7070
# NEEDSWORK: If the overspecification of the expected result is reduced, we
7171
# 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 \
7373
git fetch --depth=2 &&
7474
grep "fetch-pack< ACK .* ready" ../trace &&
7575
! grep "fetch-pack> done" ../trace

t/t5541-http-push-smart.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_expect_success 'no empty path components' '
4949
5050
# NEEDSWORK: If the overspecification of the expected result is reduced, we
5151
# 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
5353
then
5454
check_access_log exp
5555
fi
@@ -135,7 +135,7 @@ EOF
135135
test_expect_success 'used receive-pack service' '
136136
# NEEDSWORK: If the overspecification of the expected result is reduced, we
137137
# 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
139139
then
140140
check_access_log exp
141141
fi

t/t5551-http-fetch-smart.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test_expect_success 'clone http repository' '
4343
< Cache-Control: no-cache, max-age=0, must-revalidate
4444
< Content-Type: application/x-git-upload-pack-result
4545
EOF
46-
GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \
46+
GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 \
4747
git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
4848
test_cmp file clone/file &&
4949
tr '\''\015'\'' Q <err |
@@ -84,7 +84,7 @@ test_expect_success 'clone http repository' '
8484
8585
# NEEDSWORK: If the overspecification of the expected result is reduced, we
8686
# 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
8888
then
8989
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
9090
actual >actual.smudged &&
@@ -113,7 +113,7 @@ test_expect_success 'used upload-pack service' '
113113
114114
# NEEDSWORK: If the overspecification of the expected result is reduced, we
115115
# 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
117117
then
118118
check_access_log exp
119119
fi
@@ -241,7 +241,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
241241
242242
# NEEDSWORK: If the overspecification of the expected result is reduced, we
243243
# 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
245245
then
246246
tail -3 cookies.txt | sort >cookies_tail.txt &&
247247
test_cmp expect_cookies.txt cookies_tail.txt
@@ -336,7 +336,7 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' '
336336
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
337337
# Some protocol versions (e.g. 2) support fetching
338338
# 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 \
340340
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
341341
'
342342

@@ -358,7 +358,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' '
358358
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
359359
# Some protocol versions (e.g. 2) support fetching
360360
# 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 \
362362
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
363363
364364
git -C "$server" config uploadpack.allowanysha1inwant 1 &&

t/t5552-skipping-fetch-negotiator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ test_expect_success 'use ref advertisement to filter out commits' '
108108
# The ref advertisement itself is filtered when protocol v2 is used, so
109109
# use v0.
110110
(
111-
GIT_TEST_PROTOCOL_VERSION= &&
111+
GIT_TEST_PROTOCOL_VERSION=0 &&
112112
export GIT_TEST_PROTOCOL_VERSION &&
113113
trace_fetch client origin to_fetch
114114
) &&

t/t5700-protocol-v1.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ test_description='test git wire-protocol transition'
55
TEST_NO_CREATE_REPO=1
66

77
# This is a protocol-specific test.
8-
GIT_TEST_PROTOCOL_VERSION=
8+
GIT_TEST_PROTOCOL_VERSION=0
9+
export GIT_TEST_PROTOCOL_VERSION
910

1011
. ./test-lib.sh
1112

0 commit comments

Comments
 (0)