2

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/?

VonC
  • 2,653
  • 5
  • 29
  • 48
jshawl
  • 297
  • 2
  • 13

2 Answers2

2

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.

VonC
  • 2,653
  • 5
  • 29
  • 48
  • I'm still having the mismatch between the listing at http://git.jshawl.com/ and the the "txt" version at http://git.jshawl.com/?a=project_index I pasted this into a file /etc/gitweb.conf.pl – jshawl Aug 20 '12 at 14:46
  • @jessh what version of Git are you using? – VonC Aug 20 '12 at 18:51
  • the most recent version `git version 1.7.7.5 (Apple Git-26)` – jshawl Aug 20 '12 at 20:30
  • 1
    @jessh ok, just checkng if the gitweb was a recent one (and it isn't really, but I don't know if that matters). Does your `project.list` includes *all* repos, including `gitolite-admin`? – VonC Aug 20 '12 at 21:03
  • That's the thing!! I have no `project.list`. How do I get one?! – jshawl Aug 20 '12 at 22:03
  • 1
    @jessh It should be generated automatically by the gitolite installation. Another thing, the script automatically called by gitweb (if it exists) is actually `gitweb_config.perl` (https://github.com/VonC/compileEverything/blob/master/gitweb/gitweb_config.perl), which in turns calls my custom `gitweb.conf.pl`. – VonC Aug 21 '12 at 04:00
0

Since I was missing my project.list, I created it myself. Then I chmod -r 755'ed the whole repositories directory. Working now!

jshawl
  • 297
  • 2
  • 13
  • 1
    So you didn't need the `gitweb_conf.perl` addon? – VonC Aug 22 '12 at 18:13
  • 1
    I didn't. Bizarre right? – jshawl Aug 23 '12 at 02:01
  • So, is it really working? Meaning, if you declare in gitolite a repo as not visible for a certain user, will that user actually see or not said repo through your gitweb? – VonC Aug 23 '12 at 06:08
  • 1
    It seems similar to http://stackoverflow.com/questions/12041578/gitweb-404-no-projects-found/12043363#comment16182724_12043363 – VonC Aug 24 '12 at 12:21
  • @VonC: A mystery to me - similar thing here: The projects.list exists, is accessible, and so the gitweb page shows "no such projects" (but not the 404 msg). At the same time, clicking the link in the lower right displays a projects.list with the two repos I selected to be public. Now I'm hesitant to install additional perl scripts and an apache redirect rule if it turns out that that's not really required. – cfi Feb 11 '13 at 11:13
  • @cfi I understand, but I always had to add that script in order to plug gitweb into gitolite – VonC Feb 11 '13 at 12:03