Home Explore Blog CI



git

4th chunk of `Documentation/git-http-backend.adoc`
8c777af62f4316dbeb6492a88c4fa60ae08e82ba514658d10000000100000ee1

AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
ScriptAliasMatch \
	"(?x)^/git/(.*/(HEAD | \
			info/refs | \
			objects/info/[^/]+ | \
			git-(upload|receive)-pack))$" \
	/usr/libexec/git-core/git-http-backend/$1
ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
----------------------------------------------------------------

Lighttpd::
	Ensure that `mod_cgi`, `mod_alias`, `mod_auth`, `mod_setenv` are
	loaded, then set `GIT_PROJECT_ROOT` appropriately and redirect
	all requests to the CGI:
+
----------------------------------------------------------------
alias.url += ( "/git" => "/usr/lib/git-core/git-http-backend" )
$HTTP["url"] =~ "^/git" {
	cgi.assign = ("" => "")
	setenv.add-environment = (
		"GIT_PROJECT_ROOT" => "/var/www/git",
		"GIT_HTTP_EXPORT_ALL" => ""
	)
}
----------------------------------------------------------------
+
To enable anonymous read access but authenticated write access:
+
----------------------------------------------------------------
$HTTP["querystring"] =~ "service=git-receive-pack" {
	include "git-auth.conf"
}
$HTTP["url"] =~ "^/git/.*/git-receive-pack$" {
	include "git-auth.conf"
}
----------------------------------------------------------------
+
where `git-auth.conf` looks something like:
+
----------------------------------------------------------------
auth.require = (
	"/" => (
		"method" => "basic",
		"realm" => "Git Access",
		"require" => "valid-user"
	       )
)
# ...and set up auth.backend here
----------------------------------------------------------------
+
To require authentication for both reads and writes:
+
----------------------------------------------------------------
$HTTP["url"] =~ "^/git/private" {
	include "git-auth.conf"
}
----------------------------------------------------------------


ENVIRONMENT
-----------
'git http-backend' relies upon the `CGI` environment variables set
by the invoking web server, including:

* PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)
* REMOTE_USER
* REMOTE_ADDR
* CONTENT_TYPE
* QUERY_STRING
* REQUEST_METHOD

The `GIT_HTTP_EXPORT_ALL` environment variable may be passed to
'git-http-backend' to bypass the check for the "git-daemon-export-ok"
file in each repository before allowing export of that repository.

The `GIT_HTTP_MAX_REQUEST_BUFFER` environment variable (or the
`http.maxRequestBuffer` config option) may be set to change the
largest ref negotiation request that git will handle during a fetch; any
fetch requiring a larger buffer will not succeed.  This value should not
normally need to be changed, but may be helpful if you are fetching from
a repository with an extremely large number of refs.  The value can be
specified with a unit (e.g., `100M` for 100 megabytes). The default is
10 megabytes.

Clients may probe for optional protocol capabilities (like the v2
protocol) using the `Git-Protocol` HTTP header. In order to support
these, the contents of that header must appear in the `GIT_PROTOCOL`
environment variable. Most webservers will pass this header to the CGI
via the `HTTP_GIT_PROTOCOL` variable, and `git-http-backend` will
automatically copy that to `GIT_PROTOCOL`. However, some webservers may
be more selective about which headers they'll pass, in which case they
need to be configured explicitly (see the mention of `Git-Protocol` in
the Apache config from the earlier EXAMPLES section).

The backend process sets GIT_COMMITTER_NAME to '$REMOTE_USER' and
GIT_COMMITTER_EMAIL to '$\{REMOTE_USER}@http.$\{REMOTE_ADDR\}',
ensuring that any reflogs created by 'git-receive-pack' contain some
identifying information of the remote user who performed the push.

All `CGI` environment variables are available to each of the hooks
invoked by the 'git-receive-pack'.

GIT
---
Part of the linkgit:git[1] suite

Title: Git HTTP Backend Configuration and Environment Variables
Summary
The text describes the configuration of Git HTTP backend with Lighttpd, including authentication settings and environment variables, as well as the reliance on CGI environment variables set by the web server, and the use of variables like GIT_HTTP_EXPORT_ALL and GIT_PROTOCOL to control the behavior of the backend.