Skip to content

Commit f4bbb34

Browse files
committed
Merge branch 'jn/promote-proto2-to-default' into next
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
2 parents c6d3f1d + 32b7315 commit f4bbb34

14 files changed

+54
-45
lines changed

Documentation/config/protocol.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ The protocol names currently used by git are:
4545
--
4646

4747
protocol.version::
48-
Experimental. If set, clients will attempt to communicate with a
49-
server using the specified protocol version. If unset, no
50-
attempt will be made by the client to communicate using a
51-
particular protocol version, this results in protocol version 0
52-
being used.
48+
If set, clients will attempt to communicate with a server
49+
using the specified protocol version. If the server does
50+
not support it, communication falls back to version 0.
51+
If unset, the default is `2`.
5352
Supported versions:
5453
+
5554
--

protocol.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ static enum protocol_version parse_protocol_version(const char *value)
1717
enum protocol_version get_protocol_version_config(void)
1818
{
1919
const char *value;
20-
enum protocol_version retval = protocol_v0;
2120
const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION";
22-
const char *git_test_v = getenv(git_test_k);
21+
const char *git_test_v;
2322

2423
if (!git_config_get_string_const("protocol.version", &value)) {
2524
enum protocol_version version = parse_protocol_version(value);
@@ -28,19 +27,19 @@ enum protocol_version get_protocol_version_config(void)
2827
die("unknown value for config 'protocol.version': %s",
2928
value);
3029

31-
retval = version;
30+
return version;
3231
}
3332

33+
git_test_v = getenv(git_test_k);
3434
if (git_test_v && *git_test_v) {
3535
enum protocol_version env = parse_protocol_version(git_test_v);
3636

3737
if (env == protocol_unknown_version)
3838
die("unknown value for %s: %s", git_test_k, git_test_v);
39-
if (retval < env)
40-
retval = env;
39+
return env;
4140
}
4241

43-
return retval;
42+
return protocol_v2;
4443
}
4544

4645
enum protocol_version determine_protocol_version_server(void)

t/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ details.
352352
GIT_TEST_SPLIT_INDEX=<boolean> forces split-index mode on the whole
353353
test suite. Accept any boolean values that are accepted by git-config.
354354

355-
GIT_TEST_PROTOCOL_VERSION=<n>, when set, overrides the
356-
'protocol.version' setting to n if it is less than n.
355+
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
356+
default to n.
357357

358358
GIT_TEST_FULL_IN_PACK_ARRAY=<boolean> exercises the uncommon
359359
pack-objects code path where there are more than 1024 packs even if

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: 16 additions & 7 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
'
@@ -917,7 +918,10 @@ test_expect_success 'filtering by size' '
917918
git -C client fetch-pack --filter=blob:limit=0 ../server HEAD &&
918919
919920
# Ensure that object is not inadvertently fetched
920-
test_must_fail git -C client cat-file -e $(git hash-object server/one.t)
921+
commit=$(git -C server rev-parse HEAD) &&
922+
blob=$(git hash-object server/one.t) &&
923+
git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
924+
! grep "$blob" oids
921925
'
922926

923927
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
929933
git -C client fetch-pack --filter=blob:limit=0 ../server HEAD 2> err &&
930934
931935
# Ensure that object is fetched
932-
git -C client cat-file -e $(git hash-object server/one.t) &&
936+
commit=$(git -C server rev-parse HEAD) &&
937+
blob=$(git hash-object server/one.t) &&
938+
git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
939+
grep "$blob" oids &&
933940
934941
test_i18ngrep "filtering not recognized by server" err
935942
'
@@ -951,9 +958,11 @@ fetch_filter_blob_limit_zero () {
951958
git -C client fetch --filter=blob:limit=0 origin HEAD:somewhere &&
952959

953960
# Ensure that commit is fetched, but blob is not
954-
test_config -C client extensions.partialclone "arbitrary string" &&
955-
git -C client cat-file -e $(git -C "$SERVER" rev-parse two) &&
956-
test_must_fail git -C client cat-file -e $(git hash-object "$SERVER/two.t")
961+
commit=$(git -C "$SERVER" rev-parse two) &&
962+
blob=$(git hash-object server/two.t) &&
963+
git -C client rev-list --objects --missing=allow-any "$commit" >oids &&
964+
grep "$commit" oids &&
965+
! grep "$blob" oids
957966
}
958967

959968
test_expect_success 'fetch with --filter=blob:limit=0' '

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

@@ -237,7 +237,7 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
237237
EOF
238238
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
239239
# protocol v0 here.
240-
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . HEAD >actual &&
240+
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . HEAD >actual &&
241241
test_cmp expect actual
242242
'
243243

@@ -250,7 +250,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' '
250250
EOF
251251
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
252252
# protocol v0 here.
253-
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual &&
253+
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
254254
test_cmp expect actual
255255
'
256256

@@ -261,9 +261,9 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
261261
EOF
262262
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
263263
# protocol v0 here.
264-
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual &&
264+
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref --heads . >actual &&
265265
test_cmp expect actual &&
266-
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . "refs/heads/*" >actual &&
266+
GIT_TEST_PROTOCOL_VERSION=0 git ls-remote --symref . "refs/heads/*" >actual &&
267267
test_cmp expect actual
268268
'
269269

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

t/t7406-submodule-update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
960960
mv -f .gitmodules.tmp .gitmodules &&
961961
# Some protocol versions (e.g. 2) support fetching
962962
# 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 \
964964
git submodule update --init --depth=1 2>actual &&
965965
test_i18ngrep "Direct fetching of that commit failed." actual &&
966966
git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&

0 commit comments

Comments
 (0)