diff options
Diffstat (limited to 'git/cmd.py')
-rw-r--r-- | git/cmd.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -309,14 +309,23 @@ class Git(LazyMixin): def __getattr__(self, attr): return getattr(self.proc, attr) - def wait(self): + def wait(self, stderr=None): """Wait for the process and return its status code. + :param stderr: Previously read value of stderr, in case stderr is already closed. :warn: may deadlock if output or error pipes are used and not handled separately. :raise GitCommandError: if the return status is not 0""" status = self.proc.wait() + + def read_all_from_possibly_closed_stream(stream): + try: + return stream.read() + except ValueError: + return stderr or '' + if status != 0: - raise GitCommandError(self.args, status, self.proc.stderr.read()) + errstr = read_all_from_possibly_closed_stream(self.proc.stderr) + raise GitCommandError(self.args, status, errstr) # END status handling return status # END auto interrupt |