Search code examples
gitubuntusymlinkgitolite

Gitolite - adding new public key - could not symlink


I've installed the latest version of gitolite on Ubuntu:

I'm running

gitolite setup -pk user2.pub

The error I'm getting is:

FATAL: could not symlink /home/git/.gitolite/hooks/common/update to MyRepository.
git/hooks
  at /home/git/gitolite/src/lib/Gitolite/Conf/Store.pm line 330

Any thoughts on what is going on?


EDIT: Ok - so the directory

MyRepository.git/hooks

doesn't exist. There is only

MyRepository.git/.git/hooks/

What is going on with gitolite?


Solution

  • The store_common() includes:

    # override/propagate gitolite defined hooks for all repos
    ln_sf( "$rc{GL_ADMIN_BASE}/hooks/common", "*", "$repo.git/hooks" );
    

    That, in turn, calls ln_sf()

    sub ln_sf {
        trace( 3, @_ );
        my ( $srcdir, $glob, $dstdir ) = @_;
        for my $hook ( glob("$srcdir/$glob") ) {
            $hook =~ s/$srcdir\///;
            unlink "$dstdir/$hook";
            symlink "$srcdir/$hook", "$dstdir/$hook" or croak "could not symlink $srcdir/$hook to $dstdir\n";
        }
    }
    

    dstdir here seems incomplete. It should be /home/git/repositories/MyRepository.git/hooks.

    That can be because of anc incorrect initial setup.