9

I have a Redmine installation on the same server as my gitolite repositories.

In order to link my repository to my Redmine instance, I locally cloned the repo with the following command:

git clone --bare --local /home/git/repositories/my-repo.git

Just as I successfully clone the repo on the server, I can navigate through the repo on Redmine, as expected.

The thing is, as soon as I do that, I can't push anything more to the remote repo on my local machine.

When I try

git push

I get the following errors:

Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 695 bytes, done.
Total 8 (delta 6), reused 0 (delta 0)
fatal: loose object 455f30c5243ec5b5cc698b1e51bdfb23ee6c1b22 (stored in     ./objects/45/5f30c5243ec5b5cc698b1e51bdfb23ee6c1b22) is corrupt
error: unpack failed: unpack-objects abnormal exit
To git@dev.my-host.org:my-repo.git
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'git@my-host.org:my-repo.git'

Any ideas on that?

EDIT #1

The gitolite logs show the following:

2012-10-22.10:59:59     13121   ssh     ARGV=drgomesp   SOC=git-receive-pack 'my-repo.git'   FROM=187.65.248.7
2012-10-22.11:00:00     13121           access(my-repo, drgomesp, W, 'any'),-> refs/.*
2012-10-22.11:00:00     13121           trigger,Writable,access_1,ACCESS_1,my-repo,drgomesp,W,any,refs/.*
2012-10-22.11:00:00     13121   pre_git my-repo      drgomesp        W       any     -> refs/.*
2012-10-22.11:00:00     13121           system,git,shell,-c,git-receive-pack '/home/git/repositories/my-repo.git'
2012-10-22.11:00:00     13121   END
Daniel Ribeiro
  • 10,156
  • 12
  • 47
  • 79

2 Answers2

16

I managed to get it working pointing the original repo to Redmine, since both sit on the same machine, by following some simple steps:

  1. Add a repository on Redmine with the original repo of gitolite's repository. The path would be something like /home/git/repositories/my-repo.git.

  2. Initially, Redmine doesn't have any permissions to read the repository, so we fix the problem by adding the Redmine user (usually www-data or apache) to the git group by running usermod -a -G git www-data (be aware of your server's configuration, because that can be a little different, according to how you configurated gitolite.

  3. Change the UMASK property on the .gitolite.rc file, from the default value of 0077 to 0022, the equivalent of 755 (rwxr-xr-x) for directories and 644 (rw-r--r--) for files.

  4. For existing repos, you might need to run a chmod -R g+rX

If you still experience the permissions trouble with Redmine, where it opens a 404instead of the repo on the repository tab, you might have to run a chmod -R g+rX on the whole /home/git/repositories, in order to make sure the Redmine user can read all the way through the repos.

Daniel Ribeiro
  • 10,156
  • 12
  • 47
  • 79
  • 1
    Thanks for the hint. A `setfacl -R -m git:rX ~git/repositories/` did the trick for me – Pierre de LESPINAY Sep 04 '14 at 15:52
  • I get stderr: fatal: Not a git repository: '/home/git/repositories/myrepo.git' on an existing repo with commits in there. Any idea why this could happen? Running redmine 3.1. Showing a 404 in the webpage. – Gerard van den Bosch Sep 18 '15 at 12:24
1

If a git repack remote/origin/master doesn't fix the issue, check your umask (umask 0002) to avoid any writing permission issue, as mentioned in "git: can't push (unpacker error)".

Beside that, "Unpacker error Git-pushing from bare repo to staging server" summarize all the other points to check.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The repack command doesn't fix the issue. About the umask, nothing shows up. I'm not certain this is a permission issue. Any alternatives? – Daniel Ribeiro Oct 21 '12 at 18:00
  • @DanielRibeiro setting `umask 0002` on the server is still recommended though, just to see if that has any bearing on the current issue. Most of the alternatives I know of are listed in the two SO questions I reference in the answer. – VonC Oct 21 '12 at 18:19
  • And how do I do that? Just execute the command on the server? – Daniel Ribeiro Oct 21 '12 at 18:29
  • Server is ok, as 0002 and how it should be. Any alternatives? – Daniel Ribeiro Oct 21 '12 at 18:59
  • Everything seems to work fine as soon as I do chown apache on the repository, so that Redmine can read it. Then, I cannot push from local anymore. This seems weird... – Daniel Ribeiro Oct 21 '12 at 21:07
  • @DanielRibeiro what error message do you have when pushing from local, and are the gitolite logs of any interest in that case (in `~/.gitolite/logs`). Same for the Apache logs. – VonC Oct 22 '12 at 05:40
  • The error message on the local machine is the one on the end of the question. Something about a corrupt object. I'll check logs and be right back... – Daniel Ribeiro Oct 22 '12 at 10:57
  • @DanielRibeiro gitolite seems off the hook here: it allows `git-receive-pack` to execute. time to try and get that object from another source (like in http://stackoverflow.com/questions/4254389/git-corrupt-loose-object) – VonC Oct 22 '12 at 11:16
  • I never found any response from that topic, even before you pointed me there. Is there any cookbook on solving this? Are these log messages actually errors? – Daniel Ribeiro Oct 22 '12 at 11:27
  • @DanielRibeiro the logs you mention indicates that you are allowed to write on that repo. But the git-receive-pack pack. By "no answer", do you mean that http://stackoverflow.com/questions/4254389/git-corrupt-loose-object or http://www.kernel.org/pub/software/scm/git/docs/howto/recover-corrupted-blob-object.txt are not answers? – VonC Oct 22 '12 at 11:54
  • I mean this http://stackoverflow.com/questions/4254389/git-corrupt-loose-object didn't help me figure the problem out yet. I'm checking http://www.kernel.org/pub/software/scm/git/docs/howto/recover-corrupted-blob-object.txt, but I don't think it will help me much either. The weird part is, the repo stops working after I link it on Redmine. I think there is something related to that... – Daniel Ribeiro Oct 22 '12 at 11:58