path: root/t/
diff options
authorJeff King <>2013-04-13 03:33:36 (GMT)
committerJunio C Hamano <>2013-04-14 05:27:06 (GMT)
commitb0808819e5806f5ff01ffcc34db2796d180ad0d9 (patch)
treeb9643d7d4de9b0d0db0cb58102729b5e96c7dd62 /t/
parent3813a33de5f9e8224eb2bd2ebae167b3bb00ef73 (diff)
doc/http-backend: match query-string in apache half-auth example
When setting up a "half-auth" repository in which reads can be done anonymously but writes require authentication, it is best if the server can require authentication for both the ref advertisement and the actual receive-pack POSTs. This alleviates the need for the admin to set http.receivepack in the repositories, and means that the client is challenged for credentials immediately, instead of partway through the push process (and git clients older than v1.7.11.7 had trouble handling these challenges). Since detecting a push during the ref advertisement requires matching the query string, and this is non-trivial to do in Apache, we have traditionally punted and instructed users to just protect "/git-receive-pack$". This patch provides the mod_rewrite recipe to actually match the ref advertisement, which is preferred. While we're at it, let's add the recipe to our test scripts so that we can be sure that it works, and doesn't get broken (either by our changes or by changes in Apache). Signed-off-by: Jeff King <> Acked-by: Jakub Narębski <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 30 insertions, 0 deletions
diff --git a/t/ b/t/
index 4b4b4a6..8a9dc85 100755
--- a/t/
+++ b/t/
@@ -295,5 +295,35 @@ test_expect_success 'push to auth-only-for-push repo' '
test_cmp expect actual
+test_expect_success 'create repo without http.receivepack set' '
+ cd "$ROOT_PATH" &&
+ git init half-auth &&
+ (
+ cd half-auth &&
+ test_commit one
+ ) &&
+ git clone --bare half-auth "$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git"
+test_expect_success 'clone via half-auth-complete does not need password' '
+ cd "$ROOT_PATH" &&
+ set_askpass wrong &&
+ git clone "$HTTPD_URL"/half-auth-complete/smart/half-auth.git \
+ half-auth-clone &&
+ expect_askpass none
+test_expect_success 'push into half-auth-complete requires password' '
+ cd "$ROOT_PATH/half-auth-clone" &&
+ echo two >expect &&
+ test_commit two &&
+ set_askpass user@host &&
+ git push "$HTTPD_URL/half-auth-complete/smart/half-auth.git" &&
+ git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git" \
+ log -1 --format=%s >actual &&
+ expect_askpass both user@host &&
+ test_cmp expect actual