summaryrefslogtreecommitdiff
path: root/lib/git/cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git/cmd.py')
-rw-r--r--lib/git/cmd.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/git/cmd.py b/lib/git/cmd.py
index 18d1c505..5cae2998 100644
--- a/lib/git/cmd.py
+++ b/lib/git/cmd.py
@@ -38,6 +38,10 @@ class Git(object):
"""
__slots__ = ("_working_dir", "cat_file_all", "cat_file_header")
+ # CONFIGURATION
+ # The size in bytes read from stdout when copying git's output to another stream
+ max_chunk_size = 1024*64
+
class AutoInterrupt(object):
"""
Kill/Interrupt the stored process instance once this instance goes out of scope. It is
@@ -320,16 +324,22 @@ class Git(object):
stderr_value = ''
try:
if output_stream is None:
- stdout_value = proc.stdout.read().rstrip() # strip trailing "\n"
+ stdout_value, stderr_value = proc.communicate()
+ # strip trailing "\n"
+ if stdout_value.endswith("\n"):
+ stdout_value = stdout_value[:-1]
+ if stderr_value.endswith("\n"):
+ stderr_value = stderr_value[:-1]
+ status = proc.returncode
else:
- max_chunk_size = 1024*64
- stream_copy(proc.stdout, output_stream, max_chunk_size)
+ stream_copy(proc.stdout, output_stream, self.max_chunk_size)
stdout_value = output_stream
+ stderr_value = proc.stderr.read()
+ # strip trailing "\n"
+ if stderr_value.endswith("\n"):
+ stderr_value = stderr_value[:-1]
+ status = proc.wait()
# END stdout handling
- stderr_value = proc.stderr.read().rstrip() # strip trailing "\n"
-
- # waiting here should do nothing as we have finished stream reading
- status = proc.wait()
finally:
proc.stdout.close()
proc.stderr.close()
@@ -497,7 +507,7 @@ class Git(object):
def stream_object_data(self, ref):
"""As get_object_header, but returns the data as a stream
:return: (hexsha, type_string, size_as_int, stream)
- :note: This method is not threadsafe, you need one independent Command instance
+ :note: This method is not threadsafe, you need one independent Command instance
per thread to be safe !"""
cmd = self.__get_persistent_cmd("cat_file_all", "cat_file", batch=True)
hexsha, typename, size = self.__get_object_header(cmd, ref)