Skip to content

Commit 2614698

Browse files
peffgitster
authored andcommitted
t5551: test v2-to-v0 http protocol fallback
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 225bc32 commit 2614698

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

t/lib-httpd/apache.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ Alias /auth/dumb/ www/auth/dumb/
117117
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
118118
SetEnv GIT_HTTP_EXPORT_ALL
119119
</LocationMatch>
120+
<LocationMatch /smart_v0/>
121+
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
122+
SetEnv GIT_HTTP_EXPORT_ALL
123+
SetEnv GIT_PROTOCOL
124+
</LocationMatch>
120125
ScriptAlias /smart/incomplete_length/git-upload-pack incomplete-length-upload-pack-v2-http.sh/
121126
ScriptAlias /smart/incomplete_body/git-upload-pack incomplete-body-upload-pack-v2-http.sh/
122127
ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/

t/t5551-http-fetch-smart.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,4 +558,13 @@ test_expect_success 'http auth forgets bogus credentials' '
558558
expect_askpass both user@host
559559
'
560560

561+
test_expect_success 'client falls back from v2 to v0 to match server' '
562+
GIT_TRACE_PACKET=$PWD/trace \
563+
GIT_TEST_PROTOCOL_VERSION=2 \
564+
git clone $HTTPD_URL/smart_v0/repo.git repo-v0 &&
565+
# check for v0; there the HEAD symref is communicated in the capability
566+
# line; v2 uses a different syntax on each ref advertisement line
567+
grep symref=HEAD:refs/heads/ trace
568+
'
569+
561570
test_done

0 commit comments

Comments
 (0)