tags:

views:

853

answers:

2

I have successfully set up gitosis for an Android mirror (containing multiple git repositories). While adding a new .git path following writable= in gitosis.conf I managed to insert a few line breaks. Saved, committed and pushed to server when I received the following parsing error:

Traceback (most recent call last): File "/usr/bin/gitosis-run-hook", line 8, in load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-run-hook')()

File "/usr/lib/python2.5/site-packages/gitosis-0.2-py2.5.egg/gitosis/app.py", line 24, in run return app.main()

File "/usr/lib/python2.5/site-packages/gitosis-0.2-py2.5.egg/gitosis/app.py", line 38, in main self.handle_args(parser, cfg, options, args)

File "/usr/lib/python2.5/site-packages/gitosis-0.2-py2.5.egg/gitosis/run_hook.py", line 75, in handle_args post_update(cfg, git_dir)

File "/usr/lib/python2.5/site-packages/gitosis-0.2-py2.5.egg/gitosis/run_hook.py", line 33, in post_update cfg.read(os.path.join(export, '..', 'gitosis.conf'))

File "/usr/lib/python2.5/ConfigParser.py", line 267, in read self._read(fp, filename)

File "/usr/lib/python2.5/ConfigParser.py", line 490, in _read raise e

ConfigParser.ParsingError: File contains parsing errors: ./gitosis-export/../gitosis.conf

(...)

I have removed the line break and amendend the commit by

git commit -m "fix linebreak" --amend

However git push still yields the exact same error. It leads me to believe gitosis is preventing me from doing any further pushes.

How do I recover from this?

+8  A: 

I do this all the time. :-) The answer is to log on to the gitosis server and edit the copy of the config file there. In the home directory of the user that owns the gitosis instance there should be a link named .gitosis.conf (it actually points to gitosis-admin.git/gitosis.conf). Edit that file and fix the problems there; then, when you push next, it will be fine.

ebneter
Worked perfectly. I also had to do an additional $git merge origin/master
Shoan
Saved me, big time!
Ryan Alberts
+1  A: 

You can actually do something slightly more clever. Since gitosis-admin.git is a git archive, you can clone it locally, reset to a working version and commit the change. One trick is that you have to do everything as the "git" user.

We did it this way, but we plan to change to gitolite, which checks for errors before incorporating changes for just this reason.

change to an empty directory to which the "git" user has write access

sudo -H -u git git clone (gitosis repo directory)/gitosis-admin.git

cd gitosis-admin

sudo -H -u git git rebase -i (commit id of last known working state)

e.g.

sudo -H -u git git rebase -i HEAD^^

with the interactive flag, it's harder to make a mistake; follow the directions to pick only the right (known to work) commit

sudo -H -u git git push -f origin master

The -f flag forces git to do the push even though the master branch in the repo is not an ancestor of your new branch. This should fix the problem, and you should be able to push/pull as normal from your local branches.

Marc