Skip to content

Commit 295d81b

Browse files
peffgitster
authored andcommitted
docs/http-backend: mention v2 protocol
Historically there was a little bit of configuration needed at the webserver level in order to get the client's v2 protocol probes to Git. But when we introduced the v2 protocol, we never documented these. As of the previous commit, this should mostly work out of the box without any explicit configuration. But it's worth documenting this to make it clear how we expect it to work, especially in the face of webservers which don't provide all headers over the CGI interface. Or anybody who runs across this documentation but has an older version of Git (or _used_ to have an older version, and wonders why they still have a SetEnvIf line in their Apache config and whether it's still necessary). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ff6a37c commit 295d81b

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Documentation/git-http-backend.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ A simple CGI program to serve the contents of a Git repository to Git
1616
clients accessing the repository over http:// and https:// protocols.
1717
The program supports clients fetching using both the smart HTTP protocol
1818
and the backwards-compatible dumb HTTP protocol, as well as clients
19-
pushing using the smart HTTP protocol.
19+
pushing using the smart HTTP protocol. It also supports Git's
20+
more-efficient "v2" protocol if properly configured; see the
21+
discussion of `GIT_PROTOCOL` in the ENVIRONMENT section below.
2022

2123
It verifies that the directory has the magic file
2224
"git-daemon-export-ok", and it will refuse to export any Git directory
@@ -77,6 +79,18 @@ Apache 2.x::
7779
SetEnv GIT_PROJECT_ROOT /var/www/git
7880
SetEnv GIT_HTTP_EXPORT_ALL
7981
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
82+
83+
# This is not strictly necessary using Apache and a modern version of
84+
# git-http-backend, as the webserver will pass along the header in the
85+
# environment as HTTP_GIT_PROTOCOL, and http-backend will copy that into
86+
# GIT_PROTOCOL. But you may need this line (or something similar if you
87+
# are using a different webserver), or if you want to support older Git
88+
# versions that did not do that copying.
89+
#
90+
# Having the webserver set up GIT_PROTOCOL is perfectly fine even with
91+
# modern versions (and will take precedence over HTTP_GIT_PROTOCOL,
92+
# which means it can be used to override the client's request).
93+
SetEnvIf Git-Protocol ".*" GIT_PROTOCOL=$0
8094
----------------------------------------------------------------
8195
+
8296
To enable anonymous read access but authenticated write access,
@@ -264,6 +278,16 @@ a repository with an extremely large number of refs. The value can be
264278
specified with a unit (e.g., `100M` for 100 megabytes). The default is
265279
10 megabytes.
266280

281+
Clients may probe for optional protocol capabilities (like the v2
282+
protocol) using the `Git-Protocol` HTTP header. In order to support
283+
these, the contents of that header must appear in the `GIT_PROTOCOL`
284+
environment variable. Most webservers will pass this header to the CGI
285+
via the `HTTP_GIT_PROTOCOL` variable, and `git-http-backend` will
286+
automatically copy that to `GIT_PROTOCOL`. However, some webservers may
287+
be more selective about which headers they'll pass, in which case they
288+
need to be configured explicitly (see the mention of `Git-Protocol` in
289+
the Apache config from the earlier EXAMPLES section).
290+
267291
The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
268292
GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
269293
ensuring that any reflogs created by 'git-receive-pack' contain some

0 commit comments

Comments
 (0)