summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-02-14 20:54:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-14 20:54:19 (GMT)
commit0da63da7942ce810126cd54d9f72a46f3d616895 (patch)
tree19764100be710ae2c250a13b67d0f202efc9078e
parenta14aebeac330e6d58f9628a02521ea780daf0a5b (diff)
parent684ceae32dae726c6a5c693b257b156926aba8b7 (diff)
downloadgit-0da63da7942ce810126cd54d9f72a46f3d616895.zip
git-0da63da7942ce810126cd54d9f72a46f3d616895.tar.gz
git-0da63da7942ce810126cd54d9f72a46f3d616895.tar.bz2
Merge branch 'jn/promote-proto2-to-default'
The transport protocol version 2 becomes the default one. * jn/promote-proto2-to-default: fetch: default to protocol version 2 protocol test: let protocol.version override GIT_TEST_PROTOCOL_VERSION test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate config doc: protocol.version is not experimental fetch test: use more robust test for filtered objects
-rw-r--r--Documentation/config/protocol.txt9
-rw-r--r--protocol.c11
-rw-r--r--t/README4
-rwxr-xr-xt/t5400-send-pack.sh2
-rwxr-xr-xt/t5500-fetch-pack.sh23
-rwxr-xr-xt/t5512-ls-remote.sh10
-rwxr-xr-xt/t5515-fetch-merge-logic.sh3
-rwxr-xr-xt/t5516-fetch-push.sh12
-rwxr-xr-xt/t5539-fetch-http-shallow.sh2
-rwxr-xr-xt/t5541-http-push-smart.sh4
-rwxr-xr-xt/t5551-http-fetch-smart.sh12
-rwxr-xr-xt/t5552-skipping-fetch-negotiator.sh2
-rwxr-xr-xt/t5700-protocol-v1.sh3
-rwxr-xr-xt/t7406-submodule-update.sh2
14 files changed, 54 insertions, 45 deletions
diff --git a/Documentation/config/protocol.txt b/Documentation/config/protocol.txt
index bfccc07..756591d 100644
--- a/Documentation/config/protocol.txt
+++ b/Documentation/config/protocol.txt
@@ -45,11 +45,10 @@ The protocol names currently used by git are:
--
protocol.version::
- Experimental. If set, clients will attempt to communicate with a
- server using the specified protocol version. If unset, no
- attempt will be made by the client to communicate using a
- particular protocol version, this results in protocol version 0
- being used.
+ If set, clients will attempt to communicate with a server
+ using the specified protocol version. If the server does
+ not support it, communication falls back to version 0.
+ If unset, the default is `2`.
Supported versions:
+
--
diff --git a/protocol.c b/protocol.c
index 9741f05..803bef5 100644
--- a/protocol.c
+++ b/protocol.c
@@ -17,9 +17,8 @@ static enum protocol_version parse_protocol_version(const char *value)
enum protocol_version get_protocol_version_config(void)
{
const char *value;
- enum protocol_version retval = protocol_v0;
const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION";
- const char *git_test_v = getenv(git_test_k);
+ const char *git_test_v;
if (!git_config_get_string_const("protocol.version", &value)) {
enum protocol_version version = parse_protocol_version(value);
@@ -28,19 +27,19 @@ enum protocol_version get_protocol_version_config(void)
die("unknown value for config 'protocol.version': %s",
value);
- retval = version;
+ return version;
}
+ git_test_v = getenv(git_test_k);
if (git_test_v && *git_test_v) {
enum protocol_version env = parse_protocol_version(git_test_v);
if (env == protocol_unknown_version)
die("unknown value for %s: %s", git_test_k, git_test_v);
- if (retval < env)
- retval = env;
+ return env;
}
- return retval;
+ return protocol_v2;
}
enum protocol_version determine_protocol_version_server(void)
diff --git a/t/README b/t/README
index caa125b..9afd61e 100644
--- a/t/README
+++ b/t/README
@@ -352,8 +352,8 @@ details.
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
test suite. Accept any boolean values that are accepted by git-config.
-GIT_TEST_PROTOCOL_VERSION=<n>, when set, overrides the
-'protocol.version' setting to n if it is less than n.
+GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
+default to n.
GIT_TEST_FULL_IN_PACK_ARRAY=<boolean> exercises the uncommon
pack-objects code path where there are more than 1024 packs even if
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 571d620..b84618c 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' '
$shared .have
EOF
- GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \
+ GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION=0 \
git push \
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
fork HEAD:foo &&
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 6b97923..baa1a99 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -440,11 +440,12 @@ test_expect_success 'setup tests for the --stdin parameter' '
'
test_expect_success 'setup fetch refs from cmdline v[12]' '
+ cp -r client client0 &&
cp -r client client1 &&
cp -r client client2
'
-for version in '' 1 2
+for version in '' 0 1 2
do
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 &&
# 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 \
+ 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 &&
test_i18ngrep "Server does not allow request for unadvertised object" err
'
@@ -917,7 +918,10 @@ test_expect_success 'filtering by size' '
git -C client fetch-pack --filter=blob:limit=0 ../server HEAD &&
# Ensure that object is not inadvertently fetched
- test_must_fail git -C client cat-file -e $(git hash-object server/one.t)
+ commit=$(git -C server rev-parse HEAD) &&
+ blob=$(git hash-object server/one.t) &&
+ git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
+ ! grep "$blob" oids
'
test_expect_success 'filtering by size has no effect if support for it is not advertised' '
@@ -929,7 +933,10 @@ test_expect_success 'filtering by size has no effect if support for it is not ad
git -C client fetch-pack --filter=blob:limit=0 ../server HEAD 2> err &&
# Ensure that object is fetched
- git -C client cat-file -e $(git hash-object server/one.t) &&
+ commit=$(git -C server rev-parse HEAD) &&
+ blob=$(git hash-object server/one.t) &&
+ git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
+ grep "$blob" oids &&
test_i18ngrep "filtering not recognized by server" err
'
@@ -951,9 +958,11 @@ fetch_filter_blob_limit_zero () {
git -C client fetch --filter=blob:limit=0 origin HEAD:somewhere &&
# Ensure that commit is fetched, but blob is not
- test_config -C client extensions.partialclone "arbitrary string" &&
- git -C client cat-file -e $(git -C "$SERVER" rev-parse two) &&
- test_must_fail git -C client cat-file -e $(git hash-object "$SERVER/two.t")
+ commit=$(git -C "$SERVER" rev-parse two) &&
+ blob=$(git hash-object server/two.t) &&
+ git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
+ grep "$commit" oids &&
+ ! grep "$blob" oids
}
test_expect_success 'fetch with --filter=blob:limit=0' '
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 62152ba..04b3540 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -225,7 +225,7 @@ test_expect_success 'ls-remote --symref' '
EOF
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# 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
'
@@ -237,7 +237,7 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
EOF
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# 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
'
@@ -250,7 +250,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' '
EOF
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# 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
'
@@ -261,9 +261,9 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
EOF
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# 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 &&
- 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
'
diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh
index 961eb35..a9a7d50 100755
--- a/t/t5515-fetch-merge-logic.sh
+++ b/t/t5515-fetch-merge-logic.sh
@@ -8,7 +8,8 @@ test_description='Merge logic in fetch'
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# 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
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index c81ca36..f12cbef 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1151,7 +1151,7 @@ test_expect_success 'fetch exact SHA1' '
# unadvertised objects, so restrict this test to v0.
# 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 &&
test_i18ngrep "Server does not allow request for unadvertised object" err &&
test_must_fail git rev-parse --verify refs/heads/copy &&
@@ -1210,7 +1210,7 @@ do
cd shallow &&
# Some protocol versions (e.g. 2) support fetching
# 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 --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
git fetch --depth=1 ../testrepo/.git $SHA1 &&
@@ -1241,9 +1241,9 @@ do
cd shallow &&
# Some protocol versions (e.g. 2) support fetching
# 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 &&
- test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
+ test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
git fetch ../testrepo/.git $SHA1_1 &&
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
git fetch ../testrepo/.git $SHA1_1 &&
@@ -1251,7 +1251,7 @@ do
test_must_fail git cat-file commit $SHA1_2 &&
git fetch ../testrepo/.git $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 &&
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 tag -m foo mytag HEAD^ &&
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 &&
test_i18ngrep "Server does not allow request for unadvertised object" err
'
diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh
index b4ad81f..c0d02de 100755
--- a/t/t5539-fetch-http-shallow.sh
+++ b/t/t5539-fetch-http-shallow.sh
@@ -69,7 +69,7 @@ test_expect_success 'no shallow lines after receiving ACK ready' '
test_commit new-too &&
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# 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 &&
grep "fetch-pack< ACK .* ready" ../trace &&
! grep "fetch-pack> done" ../trace
diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
index 4c97078..23be8ce 100755
--- a/t/t5541-http-push-smart.sh
+++ b/t/t5541-http-push-smart.sh
@@ -49,7 +49,7 @@ test_expect_success 'no empty path components' '
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# 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
check_access_log exp
fi
@@ -135,7 +135,7 @@ EOF
test_expect_success 'used receive-pack service' '
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# 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
check_access_log exp
fi
diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
index e38e543..6788aef 100755
--- a/t/t5551-http-fetch-smart.sh
+++ b/t/t5551-http-fetch-smart.sh
@@ -43,7 +43,7 @@ test_expect_success 'clone http repository' '
< Cache-Control: no-cache, max-age=0, must-revalidate
< Content-Type: application/x-git-upload-pack-result
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 &&
test_cmp file clone/file &&
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
# 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
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
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
# 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
check_access_log exp
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
# 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
tail -3 cookies.txt | sort >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" &&
# Some protocol versions (e.g. 2) support fetching
# 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)"
'
@@ -358,7 +358,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' '
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
# Some protocol versions (e.g. 2) support fetching
# 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 "$server" config uploadpack.allowanysha1inwant 1 &&
diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh
index 8f25f4b..156c704 100755
--- a/t/t5552-skipping-fetch-negotiator.sh
+++ b/t/t5552-skipping-fetch-negotiator.sh
@@ -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
# use v0.
(
- GIT_TEST_PROTOCOL_VERSION= &&
+ GIT_TEST_PROTOCOL_VERSION=0 &&
export GIT_TEST_PROTOCOL_VERSION &&
trace_fetch client origin to_fetch
) &&
diff --git a/t/t5700-protocol-v1.sh b/t/t5700-protocol-v1.sh
index 2571eb9..022901b 100755
--- a/t/t5700-protocol-v1.sh
+++ b/t/t5700-protocol-v1.sh
@@ -5,7 +5,8 @@ test_description='test git wire-protocol transition'
TEST_NO_CREATE_REPO=1
# This is a protocol-specific test.
-GIT_TEST_PROTOCOL_VERSION=
+GIT_TEST_PROTOCOL_VERSION=0
+export GIT_TEST_PROTOCOL_VERSION
. ./test-lib.sh
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 7478f7a..4fb447a 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -960,7 +960,7 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
mv -f .gitmodules.tmp .gitmodules &&
# Some protocol versions (e.g. 2) support fetching
# 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 &&
test_i18ngrep "Direct fetching of that commit failed." actual &&
git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&