Skip to content

Commit 121f6af

Browse files
committed
fix(cmd): allow improved errors during clone operation
Related to #383
1 parent 55db0fc commit 121f6af

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Diff for: git/cmd.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,10 @@ def __del__(self):
309309
def __getattr__(self, attr):
310310
return getattr(self.proc, attr)
311311

312-
def wait(self):
312+
def wait(self, stderr=None):
313313
"""Wait for the process and return its status code.
314314
315+
:param stderr: Previously read value of stderr, in case stderr is already closed.
315316
:warn: may deadlock if output or error pipes are used and not handled separately.
316317
:raise GitCommandError: if the return status is not 0"""
317318
status = self.proc.wait()
@@ -320,7 +321,7 @@ def read_all_from_possibly_closed_stream(stream):
320321
try:
321322
return stream.read()
322323
except ValueError:
323-
return ''
324+
return stderr or ''
324325

325326
if status != 0:
326327
errstr = read_all_from_possibly_closed_stream(self.proc.stderr)

Diff for: git/repo/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
827827
if progress:
828828
handle_process_output(proc, None, progress.new_message_handler(), finalize_process)
829829
else:
830-
proc.communicate()
831-
finalize_process(proc)
830+
(stdout, stderr) = proc.communicate()
831+
finalize_process(proc, stderr=stderr)
832832
# end handle progress
833833
finally:
834834
if prev_cwd is not None:

Diff for: git/util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ def get_user_id():
150150
return "%s@%s" % (getpass.getuser(), platform.node())
151151

152152

153-
def finalize_process(proc):
153+
def finalize_process(proc, **kwargs):
154154
"""Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
155-
proc.wait()
155+
proc.wait(**kwargs)
156156

157157
#} END utilities
158158

0 commit comments

Comments
 (0)