aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-09-03 22:58:30 -0700
committerTommi Virtanen <tv@eagain.net>2007-09-03 23:26:14 -0700
commit5df4b0c4f869fd4c057127264e747a79a450f221 (patch)
treeeb208b6a62c5c1223b2961a7ce1bc9862a46a41c /gitosis
parentMake sure ~git/.ssh exists in gitosis-init. (diff)
downloadgitosis-gentoo-5df4b0c4f869fd4c057127264e747a79a450f221.tar.gz
gitosis-gentoo-5df4b0c4f869fd4c057127264e747a79a450f221.tar.bz2
gitosis-gentoo-5df4b0c4f869fd4c057127264e747a79a450f221.zip
Ensure "git init" doesn't write to stdout, and confuse a push.
The repository autocreation functionality ends up sending the stdout to the client side, and there a very confused git push can't make any sense of the protocol.
Diffstat (limited to 'gitosis')
-rw-r--r--gitosis/repository.py2
-rw-r--r--gitosis/test/test_serve.py29
2 files changed, 31 insertions, 0 deletions
diff --git a/gitosis/repository.py b/gitosis/repository.py
index 9558494..4ebbbfd 100644
--- a/gitosis/repository.py
+++ b/gitosis/repository.py
@@ -1,6 +1,7 @@
import os
import re
import subprocess
+import sys
from gitosis import util
@@ -28,6 +29,7 @@ def init(
returncode = subprocess.call(
args=args,
cwd=path,
+ stdout=sys.stderr,
close_fds=True,
env=dict(GIT_DIR='.'),
)
diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py
index ec757a4..08a4e67 100644
--- a/gitosis/test/test_serve.py
+++ b/gitosis/test/test_serve.py
@@ -189,3 +189,32 @@ def test_push_inits_if_needed_existsWithExtension():
# it.. having HEAD implies serve ran git init, which is supposed
# to be unnecessary here
eq(os.listdir(os.path.join(tmp, 'foo.git')), [])
+
+def test_push_inits_no_stdout_spam():
+ # git init has a tendency to spew to stdout, and that confuses
+ # e.g. a git push
+ tmp = util.maketemp()
+ cfg = RawConfigParser()
+ cfg.add_section('gitosis')
+ cfg.set('gitosis', 'repositories', tmp)
+ cfg.add_section('group foo')
+ cfg.set('group foo', 'members', 'jdoe')
+ cfg.set('group foo', 'writable', 'foo')
+ old_stdout = os.dup(1)
+ try:
+ new_stdout = os.tmpfile()
+ os.dup2(new_stdout.fileno(), 1)
+ serve.serve(
+ cfg=cfg,
+ user='jdoe',
+ command="git-receive-pack 'foo'",
+ )
+ finally:
+ os.dup2(old_stdout, 1)
+ os.close(old_stdout)
+ new_stdout.seek(0)
+ got = new_stdout.read()
+ new_stdout.close()
+ eq(got, '')
+ eq(os.listdir(tmp), ['foo.git'])
+ assert os.path.isfile(os.path.join(tmp, 'foo.git', 'HEAD'))