hawkeye
hawkeye

Reputation: 35732

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?

Upvotes: 1

Views: 1664

Answers (2)

ozma
ozma

Reputation: 1803

I saw the mentioned error when trying to import an old repository into gitolite.

The gitolite repositories directory contains the ".git" folder of "bare" repositories. That means if one want to import a repository into gitolite, he should do the following:
-- be sure the oldrepo is a bare git repository
-- run the folloeing as a gtolite user

cd $HOME
cp -R oldrepo/.git repositories/oldrepo.git
gitolite setup

My mistake was to put the old repository as a directory that contains a ".git". I've find out it was wrong.

For example my old repository:

os-HP /home/gitrepo/repositories $ ll scripts/.git/
total 52
drwxrwsrwx   8 gitrepo gitrepo 4096 Jan 25 10:59 .
drwxrwsrwx   3 gitrepo gitrepo 4096 Jul 26 15:48 ..
drwxrwsrwx   2 gitrepo gitrepo 4096 Jan 25 10:49 branches
-rwxrwxrwx   1 gitrepo gitrepo    8 Jan 25 10:53 COMMIT_EDITMSG
-rw-rw-r--   1 gitrepo gitrepo   91 Jan 25 10:59 config
-rwxrwxrwx   1 gitrepo gitrepo   73 Jan 25 10:49 description
-rwxrwxrwx   1 gitrepo gitrepo   23 Jan 25 10:49 HEAD
drwxrwsrwx   2 gitrepo gitrepo 4096 Jan 25 10:49 hooks
-rwxrwxrwx   1 gitrepo gitrepo  264 Jan 25 10:53 index
drwxrwsrwx   2 gitrepo gitrepo 4096 Jan 25 10:49 info
drwxrwsrwx   3 gitrepo gitrepo 4096 Jan 25 10:52 logs
drwxrwsrwx 133 gitrepo gitrepo 4096 Jun 28 08:50 objects
drwxrwsrwx   4 gitrepo gitrepo 4096 Jan 25 10:49 refs

Comparing to the testing repository that is shipped with gitolite:

ey ~/repositories $ ll testing.git/
total 40
drwx------  7 gitrepo gitrepo 4096 Jul 26 02:37 .
drwx------  5 gitrepo gitrepo 4096 Jul 26 08:46 ..
drwx------  2 gitrepo gitrepo 4096 Jul 26 02:37 branches
-rw-------  1 gitrepo gitrepo   66 Jul 26 02:37 config
-rw-------  1 gitrepo gitrepo    0 Jul 26 05:16 git-daemon-export-ok
-rw-------  1 gitrepo gitrepo  120 Jul 26 05:16 gl-conf
-rw-------  1 gitrepo gitrepo   23 Jul 26 02:37 HEAD
drwx------  2 gitrepo gitrepo 4096 Jul 26 05:13 hooks
drwx------  2 gitrepo gitrepo 4096 Jul 26 02:37 info
drwx------ 10 gitrepo gitrepo 4096 Jul 26 03:05 objects
drwx------  4 gitrepo gitrepo 4096 Jul 26 02:37 refs

Upvotes: 0

VonC
VonC

Reputation: 1326994

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.

Upvotes: 2

Related Questions