Browse Source

Merge branch 'jt/test-protocol-version' into jt/fetch-no-update-shallow-in-proto-v2

* jt/test-protocol-version:
  t5552: compensate for v2 filtering ref adv.
  tests: fix protocol version for overspecifications
  t5700: only run with protocol version 1
  t5512: compensate for v0 only sending HEAD symrefs
  t5503: fix overspecification of trace expectation
  tests: always test fetch of unreachable with v0
  t5601: check ssh command only with protocol v0
  tests: define GIT_TEST_PROTOCOL_VERSION
maint
Junio C Hamano 6 years ago
parent
commit
a51423bc68
  1. 17
      protocol.c
  2. 3
      t/README
  3. 2
      t/t5400-send-pack.sh
  4. 4
      t/t5500-fetch-pack.sh
  5. 2
      t/t5503-tagfollow.sh
  6. 18
      t/t5512-ls-remote.sh
  7. 4
      t/t5515-fetch-merge-logic.sh
  8. 22
      t/t5516-fetch-push.sh
  9. 5
      t/t5539-fetch-http-shallow.sh
  10. 14
      t/t5541-http-push-smart.sh
  11. 47
      t/t5551-http-fetch-smart.sh
  12. 5
      t/t5552-skipping-fetch-negotiator.sh
  13. 16
      t/t5601-clone.sh
  14. 3
      t/t5700-protocol-v1.sh
  15. 5
      t/t7406-submodule-update.sh

17
protocol.c

@ -17,6 +17,10 @@ static enum protocol_version parse_protocol_version(const char *value) @@ -17,6 +17,10 @@ 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);

if (!git_config_get_string_const("protocol.version", &value)) {
enum protocol_version version = parse_protocol_version(value);

@ -24,10 +28,19 @@ enum protocol_version get_protocol_version_config(void) @@ -24,10 +28,19 @@ enum protocol_version get_protocol_version_config(void)
die("unknown value for config 'protocol.version': %s",
value);

return version;
retval = version;
}

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 protocol_v0;
return retval;
}

enum protocol_version determine_protocol_version_server(void)

3
t/README

@ -343,6 +343,9 @@ marked strings" in po/README for details. @@ -343,6 +343,9 @@ marked strings" in po/README for 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_FULL_IN_PACK_ARRAY=<boolean> exercises the uncommon
pack-objects code path where there are more than 1024 packs even if
the actual number of packs in repository is below this limit. Accept

2
t/t5400-send-pack.sh

@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' ' @@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' '
$shared .have
EOF

GIT_TRACE_PACKET=$(pwd)/trace \
GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \
git push \
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
fork HEAD:foo &&

4
t/t5500-fetch-pack.sh

@ -636,7 +636,9 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a @@ -636,7 +636,9 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a
test_commit -C server 6 &&

git init client &&
test_must_fail git -C client fetch-pack ../server \
# 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 \
$(git -C server rev-parse refs/heads/master^) 2>err &&
test_i18ngrep "Server does not allow request for unadvertised object" err
'

2
t/t5503-tagfollow.sh

@ -47,7 +47,7 @@ get_needs () { @@ -47,7 +47,7 @@ get_needs () {
test -s "$1" &&
perl -alne '
next unless $F[1] eq "upload-pack<";
last if $F[2] eq "0000";
next unless $F[2] eq "want";
print $F[2], " ", $F[3];
' "$1"
}

18
t/t5512-ls-remote.sh

@ -223,7 +223,9 @@ test_expect_success 'ls-remote --symref' ' @@ -223,7 +223,9 @@ test_expect_success 'ls-remote --symref' '
$(git rev-parse refs/tags/mark1.10) refs/tags/mark1.10
$(git rev-parse refs/tags/mark1.2) refs/tags/mark1.2
EOF
git ls-remote --symref >actual &&
# Protocol v2 supports sending symrefs for refs other than HEAD, so use
# protocol v0 here.
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref >actual &&
test_cmp expect actual
'

@ -232,7 +234,9 @@ test_expect_success 'ls-remote with filtered symref (refname)' ' @@ -232,7 +234,9 @@ test_expect_success 'ls-remote with filtered symref (refname)' '
ref: refs/heads/master HEAD
1bd44cb9d13204b0fe1958db0082f5028a16eb3a HEAD
EOF
git ls-remote --symref . HEAD >actual &&
# 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 &&
test_cmp expect actual
'

@ -243,7 +247,9 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' ' @@ -243,7 +247,9 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' '
1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/foo
1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master
EOF
git ls-remote --symref --heads . >actual &&
# 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 &&
test_cmp expect actual
'

@ -252,9 +258,11 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' ' @@ -252,9 +258,11 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/foo
1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master
EOF
git ls-remote --symref --heads . >actual &&
# 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 &&
test_cmp expect actual &&
git ls-remote --symref . "refs/heads/*" >actual &&
GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . "refs/heads/*" >actual &&
test_cmp expect actual
'


4
t/t5515-fetch-merge-logic.sh

@ -6,6 +6,10 @@ @@ -6,6 +6,10 @@

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=

. ./test-lib.sh

LF='

22
t/t5516-fetch-push.sh

@ -1147,8 +1147,12 @@ test_expect_success 'fetch exact SHA1' ' @@ -1147,8 +1147,12 @@ test_expect_success 'fetch exact SHA1' '
git prune &&
test_must_fail git cat-file -t $the_commit &&

# Some protocol versions (e.g. 2) support fetching
# unadvertised objects, so restrict this test to v0.

# fetching the hidden object should fail by default
test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err &&
test_must_fail env GIT_TEST_PROTOCOL_VERSION= \
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 &&

@ -1204,7 +1208,10 @@ do @@ -1204,7 +1208,10 @@ do
mk_empty shallow &&
(
cd shallow &&
test_must_fail git fetch --depth=1 ../testrepo/.git $SHA1 &&
# 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 fetch --depth=1 ../testrepo/.git $SHA1 &&
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
git fetch --depth=1 ../testrepo/.git $SHA1 &&
git cat-file commit $SHA1
@ -1232,15 +1239,20 @@ do @@ -1232,15 +1239,20 @@ do
mk_empty shallow &&
(
cd shallow &&
test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3 &&
test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_1 &&
# Some protocol versions (e.g. 2) support fetching
# unadvertised objects, so restrict this test to v0.
test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
git fetch ../testrepo/.git $SHA1_3 &&
test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
git fetch ../testrepo/.git $SHA1_1 &&
git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true &&
git fetch ../testrepo/.git $SHA1_1 &&
git cat-file commit $SHA1_1 &&
test_must_fail git cat-file commit $SHA1_2 &&
git fetch ../testrepo/.git $SHA1_2 &&
git cat-file commit $SHA1_2 &&
test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3
test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \
git fetch ../testrepo/.git $SHA1_3
)
'
done

5
t/t5539-fetch-http-shallow.sh

@ -67,7 +67,10 @@ test_expect_success 'no shallow lines after receiving ACK ready' ' @@ -67,7 +67,10 @@ test_expect_success 'no shallow lines after receiving ACK ready' '
cd clone &&
git checkout --orphan newnew &&
test_commit new-too &&
GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" git fetch --depth=2 &&
# 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 fetch --depth=2 &&
grep "fetch-pack< ACK .* ready" ../trace &&
! grep "fetch-pack> done" ../trace
)

14
t/t5541-http-push-smart.sh

@ -47,7 +47,12 @@ test_expect_success 'no empty path components' ' @@ -47,7 +47,12 @@ test_expect_success 'no empty path components' '
cd "$ROOT_PATH" &&
git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&

check_access_log exp
# 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"
then
check_access_log exp
fi
'

test_expect_success 'clone remote repository' '
@ -128,7 +133,12 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200 @@ -128,7 +133,12 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
EOF
test_expect_success 'used receive-pack service' '
check_access_log exp
# 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"
then
check_access_log exp
fi
'

test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \

47
t/t5551-http-fetch-smart.sh

@ -43,7 +43,8 @@ test_expect_success 'clone http repository' ' @@ -43,7 +43,8 @@ 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 clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \
git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
test_cmp file clone/file &&
tr '\''\015'\'' Q <err |
sed -e "
@ -80,12 +81,18 @@ test_expect_success 'clone http repository' ' @@ -80,12 +81,18 @@ test_expect_success 'clone http repository' '
/^< Content-Length: /d
/^< Transfer-Encoding: /d
" >actual &&
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
actual >actual.smudged &&
test_cmp exp actual.smudged &&

grep "Accept-Encoding:.*gzip" actual >actual.gzip &&
test_line_count = 2 actual.gzip
# 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"
then
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
actual >actual.smudged &&
test_cmp exp actual.smudged &&

grep "Accept-Encoding:.*gzip" actual >actual.gzip &&
test_line_count = 2 actual.gzip
fi
'

test_expect_success 'fetch changes via http' '
@ -103,7 +110,13 @@ test_expect_success 'used upload-pack service' ' @@ -103,7 +110,13 @@ test_expect_success 'used upload-pack service' '
GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
POST /smart/repo.git/git-upload-pack HTTP/1.1 200
EOF
check_access_log exp

# 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"
then
check_access_log exp
fi
'

test_expect_success 'follow redirects (301)' '
@ -215,8 +228,14 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set @@ -215,8 +228,14 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
git config http.cookiefile cookies.txt &&
git config http.savecookies true &&
git ls-remote $HTTPD_URL/smart_cookies/repo.git master &&
tail -3 cookies.txt | sort >cookies_tail.txt &&
test_cmp expect_cookies.txt cookies_tail.txt

# 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"
then
tail -3 cookies.txt | sort >cookies_tail.txt &&
test_cmp expect_cookies.txt cookies_tail.txt
fi
'

test_expect_success 'transfer.hiderefs works over smart-http' '
@ -306,7 +325,10 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' ' @@ -306,7 +325,10 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' '

git init --bare test_reachable.git &&
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
# 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 test_reachable.git fetch origin "$(git rev-parse HEAD)"
'

test_expect_success 'test allowanysha1inwant with unreachable' '
@ -325,7 +347,10 @@ test_expect_success 'test allowanysha1inwant with unreachable' ' @@ -325,7 +347,10 @@ test_expect_success 'test allowanysha1inwant with unreachable' '

git init --bare test_reachable.git &&
git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
# 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 test_reachable.git fetch origin "$(git rev-parse HEAD)" &&

git -C "$server" config uploadpack.allowanysha1inwant 1 &&
git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"

5
t/t5552-skipping-fetch-negotiator.sh

@ -127,7 +127,10 @@ test_expect_success 'use ref advertisement to filter out commits' ' @@ -127,7 +127,10 @@ test_expect_success 'use ref advertisement to filter out commits' '
# not need to send any ancestors of "c3", but we still need to send "c3"
# itself.
test_config -C client fetch.negotiationalgorithm skipping &&
trace_fetch client origin to_fetch &&

# The ref advertisement itself is filtered when protocol v2 is used, so
# use v0.
GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch &&
have_sent c5 c4^ c2side &&
have_not_sent c4 c4^^ c4^^^
'

16
t/t5601-clone.sh

@ -345,7 +345,7 @@ expect_ssh () { @@ -345,7 +345,7 @@ expect_ssh () {
}

test_expect_success 'clone myhost:src uses ssh' '
git clone myhost:src ssh-clone &&
GIT_TEST_PROTOCOL_VERSION=0 git clone myhost:src ssh-clone &&
expect_ssh myhost src
'

@ -356,12 +356,12 @@ test_expect_success !MINGW,!CYGWIN 'clone local path foo:bar' ' @@ -356,12 +356,12 @@ test_expect_success !MINGW,!CYGWIN 'clone local path foo:bar' '
'

test_expect_success 'bracketed hostnames are still ssh' '
git clone "[myhost:123]:src" ssh-bracket-clone &&
GIT_TEST_PROTOCOL_VERSION=0 git clone "[myhost:123]:src" ssh-bracket-clone &&
expect_ssh "-p 123" myhost src
'

test_expect_success 'OpenSSH variant passes -4' '
git clone -4 "[myhost:123]:src" ssh-ipv4-clone &&
GIT_TEST_PROTOCOL_VERSION=0 git clone -4 "[myhost:123]:src" ssh-ipv4-clone &&
expect_ssh "-4 -p 123" myhost src
'

@ -405,7 +405,7 @@ test_expect_success 'OpenSSH-like uplink is treated as ssh' ' @@ -405,7 +405,7 @@ test_expect_success 'OpenSSH-like uplink is treated as ssh' '
test_when_finished "rm -f \"\$TRASH_DIRECTORY/uplink\"" &&
GIT_SSH="$TRASH_DIRECTORY/uplink" &&
test_when_finished "GIT_SSH=\"\$TRASH_DIRECTORY/ssh\$X\"" &&
git clone "[myhost:123]:src" ssh-bracket-clone-sshlike-uplink &&
GIT_TEST_PROTOCOL_VERSION=0 git clone "[myhost:123]:src" ssh-bracket-clone-sshlike-uplink &&
expect_ssh "-p 123" myhost src
'

@ -444,14 +444,14 @@ test_expect_success 'single quoted plink.exe in GIT_SSH_COMMAND' ' @@ -444,14 +444,14 @@ test_expect_success 'single quoted plink.exe in GIT_SSH_COMMAND' '

test_expect_success 'GIT_SSH_VARIANT overrides plink detection' '
copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
GIT_SSH_VARIANT=ssh \
git clone "[myhost:123]:src" ssh-bracket-clone-variant-1 &&
GIT_TEST_PROTOCOL_VERSION=0 GIT_SSH_VARIANT=ssh \
git clone "[myhost:123]:src" ssh-bracket-clone-variant-1 &&
expect_ssh "-p 123" myhost src
'

test_expect_success 'ssh.variant overrides plink detection' '
copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
git -c ssh.variant=ssh \
GIT_TEST_PROTOCOL_VERSION=0 git -c ssh.variant=ssh \
clone "[myhost:123]:src" ssh-bracket-clone-variant-2 &&
expect_ssh "-p 123" myhost src
'
@ -482,7 +482,7 @@ counter=0 @@ -482,7 +482,7 @@ counter=0
# $3 path
test_clone_url () {
counter=$(($counter + 1))
test_might_fail git clone "$1" tmp$counter &&
test_might_fail env GIT_TEST_PROTOCOL_VERSION=0 git clone "$1" tmp$counter &&
shift &&
expect_ssh "$@"
}

3
t/t5700-protocol-v1.sh

@ -4,6 +4,9 @@ test_description='test git wire-protocol transition' @@ -4,6 +4,9 @@ test_description='test git wire-protocol transition'

TEST_NO_CREATE_REPO=1

# This is a protocol-specific test.
GIT_TEST_PROTOCOL_VERSION=

. ./test-lib.sh

# Test protocol v1 with 'git://' transport

5
t/t7406-submodule-update.sh

@ -943,7 +943,10 @@ test_expect_success 'submodule update clone shallow submodule outside of depth' @@ -943,7 +943,10 @@ test_expect_success 'submodule update clone shallow submodule outside of depth'
cd super3 &&
sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
mv -f .gitmodules.tmp .gitmodules &&
test_must_fail git submodule update --init --depth=1 2>actual &&
# 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 submodule update --init --depth=1 2>actual &&
test_i18ngrep "Direct fetching of that commit failed." actual &&
git -C ../submodule config uploadpack.allowReachableSHA1InWant true &&
git submodule update --init --depth=1 >actual &&

Loading…
Cancel
Save