The Virtualmin GIT plugin implements the outdated "dumb HTTP (web-dav)" method for git push functionality rather than the much improved Smart HTTP Transport.
The advantages of the Smart HTTP transport are numerous. To name a few, git hooks are executed when doing a push via Smart HTTP but not when using dumb http. The speed of git transactions (push/pull) are significantly improved.
Implementing Smart HTTP is straight forward. The changes required are as follows:
Create ~cgi-bin/wrapper.cgi
in order to pass environment variables to git-http-backend
#!/bin/sh
export GIT_PROJECT_ROOT=/home/sandbox/public_html/git
export GIT_HTTP_EXPORT_ALL=1
export REMOTE_USER=$REDIRECT_REMOTE_USER
exec /usr/libexec/git-core/git-http-backend
Add the following directives to the virtual-host config. Note, the "ScriptAliasMatch" allows gitweb and git-http-backend to be served from the same url /git
ScriptAliasMatch \
"(?x)^/git/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/home/sandbox/cgi-bin/wrapper.cgi/$1
<Files "git-http-backend">
AuthType Basic
AuthName "Git Access"
AuthUserFile /home/sandbox/etc/git.basic.passwd
Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#)
Require valid-user
</Files>
The current method of initializing repositories needs to include this git command git config http.receivepack true
to enable users to push.
I've implemented this setup on a Virtualmin virtual-host and it works as expected.
Additional documentation on implementing Smart HTTP functionality can be found here.
Comments
Submitted by imcdona on Fri, 01/26/2018 - 13:54 Comment #1
You'll also need to set the repo as shared in addition to above
git config http.receivepack true
git config core.sharedRepository group
Submitted by JamieCameron on Sat, 01/27/2018 - 13:53 Comment #2
Thanks, I didn't know about this - I'll look into implementing the change you suggested.
Submitted by imcdona on Sat, 01/27/2018 - 14:09 Comment #3
You'll need to change the < files > directive to include the name of the wrapper script. I mistakenly included the wrong file name. The correct name would be wrapper.cgi
Thanks
Submitted by mmoxnes on Fri, 09/11/2020 - 07:09 Pro Licensee Comment #4
Hi, is there any progress on this, was reported in january 2018, now september 2020 still listed as open....
Submitted by JamieCameron on Fri, 09/11/2020 - 17:39 Comment #5
No we haven't worked on this yet, sorry.
Submitted by sebaj80 on Thu, 06/10/2021 - 08:09 Comment #6
Hi! I did all the steps (including comments after post) and I have error 500 :(