git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sylvain Rabot <sylvain@abstraction.fr>
To: git <git@vger.kernel.org>
Subject: Make Gitweb behave like Apache mod_userdir
Date: Sun, 15 Nov 2009 11:04:03 +0100	[thread overview]
Message-ID: <7fce93be0911150204h259b7424md251c54186d05b7d@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]

Hello,

I contact you because I spent quite some time to make something pretty
basic with gitweb.
I made gitweb behave a bit like UserDir module will in apache.
In fact it's only configuration but I think it could be useful to others.

Basicly it allows users of your server who use git to be able to use
gitweb to browse their own root project. E.G. :

Alice's private repos :

/home/alice/git/product_a.git (cloned from /var/git/product_a.git)
/home/alice/git/product_b.git (cloned from /var/git/product_b.git)
/home/alice/git/product_c.git (cloned from /var/git/product_c.git)

Alice's links to her repos which she wants to be able to browse with gitweb :

/home/alice/gitweb/product_a -> /home/alice/git/product_a.git/.git
/home/alice/gitweb/product_c -> /home/alice/git/product_c.git/.git

Bare repos :

/var/git/product_a.git
/var/git/product_b.git
/var/git/product_c.git
/var/git/product_d.git

/etc/gitweb.conf :

$projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/var/git/";

Apache configuration :

RewriteRule ^/~([^\/]+)/?$  /cgi-bin/gitweb.cgi
[QSA,E=GITWEB_PROJECTROOT:/home/$1/gitweb/,L,PT]

So now all users with a gitweb folder in their home will be able to
browse all git repos in it through http://<host>/~<user>.

You will find a patch enclosed which try to describe best what I did
and why in the gitweb/README.

Regards.

[-- Attachment #2: userdirstyle.patch --]
[-- Type: application/octet-stream, Size: 1490 bytes --]

diff --git a/gitweb/README b/gitweb/README
index 66c6a93..6f733e6 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -306,8 +306,10 @@ repositories, you can configure apache like this:
     DocumentRoot /pub/git
     SetEnv	GITWEB_CONFIG	/etc/gitweb.conf
     RewriteEngine on
+
     # make the front page an internal rewrite to the gitweb script
     RewriteRule ^/$  /cgi-bin/gitweb.cgi
+
     # make access for "dumb clients" work
     RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI}  [L,PT]
 </VirtualHost>
@@ -332,6 +334,20 @@ something like the following in your gitweb.conf (or gitweb_config.perl) file:
   $my_uri = "/";
   $home_link = "/";
 
+If you want gitweb to act a bit like UserDir mod in apache, knowing, http://<host>/~<user> 
+will list all git repos of <user> located in a special directory in his home (/home/<user>/gitweb/), 
+do the following steps :
+
+Add this to the VirtualHost section of your apache configuration file :
+
+   RewriteRule ^/~([^\/]+)/?$  /cgi-bin/gitweb.cgi [QSA,E=GITWEB_PROJECTROOT:/home/$1/gitweb/,L,PT]
+
+Modify your gitweb.conf file, located at /etc/gitweb.conf in this example, with :
+
+   $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/path/to/the/defaul/project/root"; 
+
+Thus, each user with a gitweb folder in his home will be able to browse it with gitweb.
+/!\ The gitweb folder and user's home folder must be readable by the webserver user.
 
 PATH_INFO usage
 -----------------------

             reply	other threads:[~2009-11-15 10:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-15 10:04 Sylvain Rabot [this message]
2009-11-15 21:03 ` Make Gitweb behave like Apache mod_userdir Junio C Hamano
2009-11-17 13:58   ` Jakub Narebski
2009-11-17 15:51     ` Sylvain Rabot
2009-11-17 18:12       ` Jakub Narebski
2009-11-17 19:56         ` Sylvain Rabot
2009-11-17 20:15 ` Junio C Hamano
2009-11-17 20:24   ` Sylvain Rabot
2009-11-17 22:10     ` Junio C Hamano
2009-11-17 22:54       ` Sylvain Rabot
2009-11-17 23:40         ` Junio C Hamano
2009-11-17 23:52           ` J.H.
2009-11-17 22:59       ` J.H.
2009-11-17 23:46         ` Junio C Hamano
2009-11-17 23:59           ` J.H.
2009-11-18  0:14             ` Junio C Hamano
2009-11-18  0:00           ` J.H.
2009-11-18  0:16         ` Sylvain Rabot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fce93be0911150204h259b7424md251c54186d05b7d@mail.gmail.com \
    --to=sylvain@abstraction.fr \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).