aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-11-15 19:00:02 +0200
committerTommi Virtanen <tv@eagain.net>2007-11-15 19:02:55 +0200
commit810179e4d4665d608488cabbb22ea7be2d5dd95e (patch)
treeb6a25b9bfed12fb01b5b8af10c8ca6aae8b0bb0b
parentMake gitosis-serve pass through environment to git-shell. (diff)
downloadgitosis-gentoo-810179e4d4665d608488cabbb22ea7be2d5dd95e.tar.gz
gitosis-gentoo-810179e4d4665d608488cabbb22ea7be2d5dd95e.tar.bz2
gitosis-gentoo-810179e4d4665d608488cabbb22ea7be2d5dd95e.zip
Make repository.export work with newer git.
gitosis-init and the post-update hook used to fail with GitCheckoutIndexError, when run with git >=1.5.3, which made checkout-index require GIT_WORK_TREE, jump through hoops to provide it, but still be backwards compatible with older git. Thanks to Garry Dolley for hunting the bug.
-rw-r--r--gitosis/repository.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/gitosis/repository.py b/gitosis/repository.py
index 17b50b2..8746144 100644
--- a/gitosis/repository.py
+++ b/gitosis/repository.py
@@ -1,3 +1,4 @@
+import errno
import os
import re
import subprocess
@@ -107,9 +108,13 @@ class GitCheckoutIndexError(GitExportError):
"""git checkout-index failed"""
def export(git_dir, path):
- # it's a literal prefix for git, a trailing slash is needed to
- # extract to the subdirectory
- path = os.path.join(path, '')
+ try:
+ os.mkdir(path)
+ except OSError, e:
+ if e.errno == errno.EEXIST:
+ pass
+ else:
+ raise
returncode = subprocess.call(
args=[
'git',
@@ -121,6 +126,11 @@ def export(git_dir, path):
)
if returncode != 0:
raise GitReadTreeError('exit status %d' % returncode)
+ # jumping through hoops to be compatible with git versions
+ # that don't have --work-tree=
+ env = {}
+ env.update(os.environ)
+ env['GIT_WORK_TREE'] = '.'
returncode = subprocess.call(
args=[
'git',
@@ -128,9 +138,10 @@ def export(git_dir, path):
'checkout-index',
'-a',
'-f',
- '--prefix=%s' % path,
],
+ cwd=path,
close_fds=True,
+ env=env,
)
if returncode != 0:
raise GitCheckoutIndexError('exit status %d' % returncode)