]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5551: test v2-to-v0 http protocol fallback
authorJeff King <peff@peff.net>
Fri, 10 Sep 2021 14:04:42 +0000 (10:04 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Sep 2021 22:34:58 +0000 (15:34 -0700)
Since we use the v2 protocol by default, the connection of a v2 client
to a v2 server is well covered by the test suite. And with the
GIT_TEST_PROTOCOL_VERSION knob, we can easily test a v0 client
connecting to a v2-aware server (which will then just speak v0). But we
have no regular tests that a v2 client, when encountering a non-v2-aware
server, will correctly fall back to using v0.

In theory this is a job for the cross-version tests in t/interop, but:

  - they cover only git:// and file:// clones

  - they are not part of the usual test suite, so nobody ever runs them
    anyway

Since using v2 over http requires configuring the web server to pass
along the Git-Protocol header, we can easily create a situation where
the server does not respect the v2 probe, and the conversation falls
back to v0.

This works just fine. This new test is not about fixing any particular
bug, but just making sure that the system works (and continues to work)
as expected.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-httpd/apache.conf
t/t5551-http-fetch-smart.sh

index afa91e38b0e2130cc27de6a40c3498b88eb8d122..1321357d8be2e9544a92ca7a6ac23b91b29d6db5 100644 (file)
@@ -117,6 +117,11 @@ Alias /auth/dumb/ www/auth/dumb/
        SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
        SetEnv GIT_HTTP_EXPORT_ALL
 </LocationMatch>
+<LocationMatch /smart_v0/>
+       SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
+       SetEnv GIT_HTTP_EXPORT_ALL
+       SetEnv GIT_PROTOCOL
+</LocationMatch>
 ScriptAlias /smart/incomplete_length/git-upload-pack incomplete-length-upload-pack-v2-http.sh/
 ScriptAlias /smart/incomplete_body/git-upload-pack incomplete-body-upload-pack-v2-http.sh/
 ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/
index 4f87d90c5bd9e0c796cb236c78fbf9b74ca6f3b7..cffc47a8e3b0d3e3ca8f51f1fdba30e597e3844e 100755 (executable)
@@ -558,4 +558,13 @@ test_expect_success 'http auth forgets bogus credentials' '
        expect_askpass both user@host
 '
 
+test_expect_success 'client falls back from v2 to v0 to match server' '
+       GIT_TRACE_PACKET=$PWD/trace \
+       GIT_TEST_PROTOCOL_VERSION=2 \
+       git clone $HTTPD_URL/smart_v0/repo.git repo-v0 &&
+       # check for v0; there the HEAD symref is communicated in the capability
+       # line; v2 uses a different syntax on each ref advertisement line
+       grep symref=HEAD:refs/heads/ trace
+'
+
 test_done