Gitweb document root with gitolite

I'm on Mac OsX, trying to host my own git server. I've got gitolite running perfectly.

However, I have a folder called "git" in my Sites directory, such that visiting http://git.example.com points to that directory.

How can I get Gitweb's document root to point to my gitolite "repositories" folder in /Users/me/repositories/?


You need to add a gitweb.conf.pl file (like this one) which:

  • will be called by gitweb (if that file exists and defines a export_auth_hook sub, gitweb.cgi calls it)
  • will specify where the git repos are
  • will call gitolite

That would include:

$ENV{GL_REPO_BASE_ABS} = "$ENV{HOME}/repositories";
$export_auth_hook = sub {
    my $repo = shift;
    my $user = $ENV{GL_USER};
    # gitweb passes us the full repo path; so we strip the beginning
    # and the end, to get the repo name as it is specified in gitolite conf
    return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;

    # check for (at least) "R" permission
    my $ret = &access( $repo, $user, 'R', 'any' );
    my $res = $ret !~ /DENIED/;
    return ($ret !~ /DENIED/);
};

With access() being a function of gitolite/src/lib/Gitolite/Conf/Load.pm.

Your httpd.conf would then call the gitweb.cgi script like in this one.