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>
This commit is contained in:
parent
b9ab170752
commit
8a1b0978ab
@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' '
|
|||||||
$shared .have
|
$shared .have
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \
|
GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git push \
|
git push \
|
||||||
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
|
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
|
||||||
fork HEAD:foo &&
|
fork HEAD:foo &&
|
||||||
|
@ -440,11 +440,12 @@ test_expect_success 'setup tests for the --stdin parameter' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'setup fetch refs from cmdline v[12]' '
|
test_expect_success 'setup fetch refs from cmdline v[12]' '
|
||||||
|
cp -r client client0 &&
|
||||||
cp -r client client1 &&
|
cp -r client client1 &&
|
||||||
cp -r client client2
|
cp -r client client2
|
||||||
'
|
'
|
||||||
|
|
||||||
for version in '' 1 2
|
for version in '' 0 1 2
|
||||||
do
|
do
|
||||||
test_expect_success "protocol.version=$version fetch refs from cmdline" "
|
test_expect_success "protocol.version=$version fetch refs from cmdline" "
|
||||||
(
|
(
|
||||||
@ -638,7 +639,7 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a
|
|||||||
git init client &&
|
git init client &&
|
||||||
# Some protocol versions (e.g. 2) support fetching
|
# Some protocol versions (e.g. 2) support fetching
|
||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= git -C client fetch-pack ../server \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C client fetch-pack ../server \
|
||||||
$(git -C server rev-parse refs/heads/master^) 2>err &&
|
$(git -C server rev-parse refs/heads/master^) 2>err &&
|
||||||
test_i18ngrep "Server does not allow request for unadvertised object" err
|
test_i18ngrep "Server does not allow request for unadvertised object" err
|
||||||
'
|
'
|
||||||
|
@ -225,7 +225,7 @@ test_expect_success 'ls-remote --symref' '
|
|||||||
EOF
|
EOF
|
||||||
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
||||||
# protocol v0 here.
|
# protocol v0 here.
|
||||||
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref >actual &&
|
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
|
|||||||
EOF
|
EOF
|
||||||
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
||||||
# protocol v0 here.
|
# protocol v0 here.
|
||||||
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . HEAD >actual &&
|
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . HEAD >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' '
|
|||||||
EOF
|
EOF
|
||||||
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
||||||
# protocol v0 here.
|
# protocol v0 here.
|
||||||
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual &&
|
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -260,9 +260,9 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
|
|||||||
EOF
|
EOF
|
||||||
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
|
||||||
# protocol v0 here.
|
# protocol v0 here.
|
||||||
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual &&
|
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
|
||||||
test_cmp expect actual &&
|
test_cmp expect actual &&
|
||||||
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . "refs/heads/*" >actual &&
|
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . "refs/heads/*" >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ test_description='Merge logic in fetch'
|
|||||||
|
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
GIT_TEST_PROTOCOL_VERSION=
|
GIT_TEST_PROTOCOL_VERSION=0
|
||||||
|
export GIT_TEST_PROTOCOL_VERSION
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
@ -1151,7 +1151,7 @@ test_expect_success 'fetch exact SHA1' '
|
|||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
|
|
||||||
# fetching the hidden object should fail by default
|
# fetching the hidden object should fail by default
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
|
git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
|
||||||
test_i18ngrep "Server does not allow request for unadvertised object" err &&
|
test_i18ngrep "Server does not allow request for unadvertised object" err &&
|
||||||
test_must_fail git rev-parse --verify refs/heads/copy &&
|
test_must_fail git rev-parse --verify refs/heads/copy &&
|
||||||
@ -1210,7 +1210,7 @@ do
|
|||||||
cd shallow &&
|
cd shallow &&
|
||||||
# Some protocol versions (e.g. 2) support fetching
|
# Some protocol versions (e.g. 2) support fetching
|
||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch --depth=1 ../testrepo/.git $SHA1 &&
|
git fetch --depth=1 ../testrepo/.git $SHA1 &&
|
||||||
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
|
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
|
||||||
git fetch --depth=1 ../testrepo/.git $SHA1 &&
|
git fetch --depth=1 ../testrepo/.git $SHA1 &&
|
||||||
@ -1241,9 +1241,9 @@ do
|
|||||||
cd shallow &&
|
cd shallow &&
|
||||||
# Some protocol versions (e.g. 2) support fetching
|
# Some protocol versions (e.g. 2) support fetching
|
||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch ../testrepo/.git $SHA1_3 &&
|
git fetch ../testrepo/.git $SHA1_3 &&
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch ../testrepo/.git $SHA1_1 &&
|
git fetch ../testrepo/.git $SHA1_1 &&
|
||||||
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
|
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
|
||||||
git fetch ../testrepo/.git $SHA1_1 &&
|
git fetch ../testrepo/.git $SHA1_1 &&
|
||||||
@ -1251,7 +1251,7 @@ do
|
|||||||
test_must_fail git cat-file commit $SHA1_2 &&
|
test_must_fail git cat-file commit $SHA1_2 &&
|
||||||
git fetch ../testrepo/.git $SHA1_2 &&
|
git fetch ../testrepo/.git $SHA1_2 &&
|
||||||
git cat-file commit $SHA1_2 &&
|
git cat-file commit $SHA1_2 &&
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch ../testrepo/.git $SHA1_3 2>err &&
|
git fetch ../testrepo/.git $SHA1_3 2>err &&
|
||||||
test_i18ngrep "remote error:.*not our ref.*$SHA1_3\$" err
|
test_i18ngrep "remote error:.*not our ref.*$SHA1_3\$" err
|
||||||
)
|
)
|
||||||
@ -1291,7 +1291,7 @@ test_expect_success 'peeled advertisements are not considered ref tips' '
|
|||||||
git -C testrepo commit --allow-empty -m two &&
|
git -C testrepo commit --allow-empty -m two &&
|
||||||
git -C testrepo tag -m foo mytag HEAD^ &&
|
git -C testrepo tag -m foo mytag HEAD^ &&
|
||||||
oid=$(git -C testrepo rev-parse mytag^{commit}) &&
|
oid=$(git -C testrepo rev-parse mytag^{commit}) &&
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch testrepo $oid 2>err &&
|
git fetch testrepo $oid 2>err &&
|
||||||
test_i18ngrep "Server does not allow request for unadvertised object" err
|
test_i18ngrep "Server does not allow request for unadvertised object" err
|
||||||
'
|
'
|
||||||
|
@ -69,7 +69,7 @@ test_expect_success 'no shallow lines after receiving ACK ready' '
|
|||||||
test_commit new-too &&
|
test_commit new-too &&
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION= \
|
GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git fetch --depth=2 &&
|
git fetch --depth=2 &&
|
||||||
grep "fetch-pack< ACK .* ready" ../trace &&
|
grep "fetch-pack< ACK .* ready" ../trace &&
|
||||||
! grep "fetch-pack> done" ../trace
|
! grep "fetch-pack> done" ../trace
|
||||||
|
@ -49,7 +49,7 @@ test_expect_success 'no empty path components' '
|
|||||||
|
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
if test -z "$GIT_TEST_PROTOCOL_VERSION"
|
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
|
||||||
then
|
then
|
||||||
check_access_log exp
|
check_access_log exp
|
||||||
fi
|
fi
|
||||||
@ -135,7 +135,7 @@ EOF
|
|||||||
test_expect_success 'used receive-pack service' '
|
test_expect_success 'used receive-pack service' '
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
if test -z "$GIT_TEST_PROTOCOL_VERSION"
|
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
|
||||||
then
|
then
|
||||||
check_access_log exp
|
check_access_log exp
|
||||||
fi
|
fi
|
||||||
|
@ -43,7 +43,7 @@ test_expect_success 'clone http repository' '
|
|||||||
< Cache-Control: no-cache, max-age=0, must-revalidate
|
< Cache-Control: no-cache, max-age=0, must-revalidate
|
||||||
< Content-Type: application/x-git-upload-pack-result
|
< Content-Type: application/x-git-upload-pack-result
|
||||||
EOF
|
EOF
|
||||||
GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \
|
GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
|
git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
|
||||||
test_cmp file clone/file &&
|
test_cmp file clone/file &&
|
||||||
tr '\''\015'\'' Q <err |
|
tr '\''\015'\'' Q <err |
|
||||||
@ -84,7 +84,7 @@ test_expect_success 'clone http repository' '
|
|||||||
|
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
if test -z "$GIT_TEST_PROTOCOL_VERSION"
|
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
|
||||||
then
|
then
|
||||||
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
|
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
|
||||||
actual >actual.smudged &&
|
actual >actual.smudged &&
|
||||||
@ -113,7 +113,7 @@ test_expect_success 'used upload-pack service' '
|
|||||||
|
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
if test -z "$GIT_TEST_PROTOCOL_VERSION"
|
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
|
||||||
then
|
then
|
||||||
check_access_log exp
|
check_access_log exp
|
||||||
fi
|
fi
|
||||||
@ -241,7 +241,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
|
|||||||
|
|
||||||
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
# NEEDSWORK: If the overspecification of the expected result is reduced, we
|
||||||
# might be able to run this test in all protocol versions.
|
# might be able to run this test in all protocol versions.
|
||||||
if test -z "$GIT_TEST_PROTOCOL_VERSION"
|
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
|
||||||
then
|
then
|
||||||
tail -3 cookies.txt | sort >cookies_tail.txt &&
|
tail -3 cookies.txt | sort >cookies_tail.txt &&
|
||||||
test_cmp expect_cookies.txt cookies_tail.txt
|
test_cmp expect_cookies.txt cookies_tail.txt
|
||||||
@ -336,7 +336,7 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' '
|
|||||||
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
|
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
|
||||||
# Some protocol versions (e.g. 2) support fetching
|
# Some protocol versions (e.g. 2) support fetching
|
||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
|
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' '
|
|||||||
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
|
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
|
||||||
# Some protocol versions (e.g. 2) support fetching
|
# Some protocol versions (e.g. 2) support fetching
|
||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
|
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
|
||||||
|
|
||||||
git -C "$server" config uploadpack.allowanysha1inwant 1 &&
|
git -C "$server" config uploadpack.allowanysha1inwant 1 &&
|
||||||
|
@ -108,7 +108,7 @@ test_expect_success 'use ref advertisement to filter out commits' '
|
|||||||
# The ref advertisement itself is filtered when protocol v2 is used, so
|
# The ref advertisement itself is filtered when protocol v2 is used, so
|
||||||
# use v0.
|
# use v0.
|
||||||
(
|
(
|
||||||
GIT_TEST_PROTOCOL_VERSION= &&
|
GIT_TEST_PROTOCOL_VERSION=0 &&
|
||||||
export GIT_TEST_PROTOCOL_VERSION &&
|
export GIT_TEST_PROTOCOL_VERSION &&
|
||||||
trace_fetch client origin to_fetch
|
trace_fetch client origin to_fetch
|
||||||
) &&
|
) &&
|
||||||
|
@ -5,7 +5,8 @@ test_description='test git wire-protocol transition'
|
|||||||
TEST_NO_CREATE_REPO=1
|
TEST_NO_CREATE_REPO=1
|
||||||
|
|
||||||
# This is a protocol-specific test.
|
# This is a protocol-specific test.
|
||||||
GIT_TEST_PROTOCOL_VERSION=
|
GIT_TEST_PROTOCOL_VERSION=0
|
||||||
|
export GIT_TEST_PROTOCOL_VERSION
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
@ -960,7 +960,7 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
|
|||||||
mv -f .gitmodules.tmp .gitmodules &&
|
mv -f .gitmodules.tmp .gitmodules &&
|
||||||
# Some protocol versions (e.g. 2) support fetching
|
# Some protocol versions (e.g. 2) support fetching
|
||||||
# unadvertised objects, so restrict this test to v0.
|
# unadvertised objects, so restrict this test to v0.
|
||||||
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
|
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
|
||||||
git submodule update --init --depth=1 2>actual &&
|
git submodule update --init --depth=1 2>actual &&
|
||||||
test_i18ngrep "Direct fetching of that commit failed." actual &&
|
test_i18ngrep "Direct fetching of that commit failed." actual &&
|
||||||
git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
|
git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
|
||||||
|
Loading…
Reference in New Issue
Block a user