浏览代码

Got rid of 'Unpacking objects' messages produced by git-receive-pack. Unfortunately there's no command line options to silence this message, so the only way is to redirect stderr.

Chris Eberle 13 年之前
父节点
当前提交
0619b382f9
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 7 1
      dulwich/client.py
  2. 1 1
      dulwich/tests/compat/test_client.py

+ 7 - 1
dulwich/client.py

@@ -524,6 +524,11 @@ class SubprocessGitClient(TraditionalGitClient):
 
     def __init__(self, *args, **kwargs):
         self._connection = None
+        self._redirect_stderr = None
+        if 'redirect_stderr' in kwargs:
+            if kwargs['redirect_stderr']:
+                self._redirect_stderr = subprocess.PIPE
+            del kwargs['redirect_stderr']
         GitClient.__init__(self, *args, **kwargs)
 
     def _connect(self, service, path):
@@ -531,7 +536,8 @@ class SubprocessGitClient(TraditionalGitClient):
         argv = ['git', service, path]
         p = SubprocessWrapper(
             subprocess.Popen(argv, bufsize=0, stdin=subprocess.PIPE,
-                             stdout=subprocess.PIPE))
+                             stdout=subprocess.PIPE,
+                             stderr=self._redirect_stderr))
         return Protocol(p.read, p.write,
                         report_activity=self._report_activity), p.can_read
 

+ 1 - 1
dulwich/tests/compat/test_client.py

@@ -272,7 +272,7 @@ class DulwichSubprocessClientTest(CompatTestCase, DulwichClientTestBase):
         CompatTestCase.tearDown(self)
 
     def _client(self):
-        return client.SubprocessGitClient()
+        return client.SubprocessGitClient(redirect_stderr=True)
 
     def _build_path(self, path):
         return self.gitroot + path