Skip to content

Commit 5077fc7

Browse files
committed
Return all the stderr messge after an error is detected for pull()
1 parent e836e5c commit 5077fc7

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

git/cmd.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def __del__(self):
307307
def __getattr__(self, attr):
308308
return getattr(self.proc, attr)
309309

310-
def wait(self, stderr=None):
310+
def wait(self, stderr=''):
311311
"""Wait for the process and return its status code.
312312
313313
:param stderr: Previously read value of stderr, in case stderr is already closed.
@@ -317,7 +317,7 @@ def wait(self, stderr=None):
317317

318318
def read_all_from_possibly_closed_stream(stream):
319319
try:
320-
return stream.read()
320+
return stderr + stream.read()
321321
except ValueError:
322322
return stderr or ''
323323

@@ -678,7 +678,7 @@ def _kill_process(pid):
678678
# strip trailing "\n"
679679
if stderr_value.endswith(b"\n"):
680680
stderr_value = stderr_value[:-1]
681-
status = proc.wait()
681+
status = proc.wait(stderr=stderr_value)
682682
# END stdout handling
683683
finally:
684684
proc.stdout.close()

git/remote.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -570,21 +570,36 @@ def _get_fetch_info_from_stderr(self, proc, progress):
570570

571571
progress_handler = progress.new_message_handler()
572572

573+
error_message = None
574+
stderr_text = None
575+
573576
for line in proc.stderr:
574577
line = force_text(line)
575578
for pline in progress_handler(line):
576579
if line.startswith('fatal:') or line.startswith('error:'):
577-
raise GitCommandError(("Error when fetching: %s" % line,), 2)
580+
error_message = "Error when fetching: %s" % (line,)
581+
break
582+
578583
# END handle special messages
579584
for cmd in cmds:
580585
if len(line) > 1 and line[0] == ' ' and line[1] == cmd:
581586
fetch_info_lines.append(line)
582587
continue
583588
# end find command code
584589
# end for each comand code we know
590+
591+
if error_message is not None:
592+
break
585593
# end for each line progress didn't handle
594+
595+
if error_message is not None:
596+
stderr_text = proc.stderr.read()
597+
586598
# end
587-
finalize_process(proc)
599+
finalize_process(proc, stderr=stderr_text)
600+
601+
if error_message is not None:
602+
raise GitCommandError( error_message, 2, stderr=stderr_text )
588603

589604
# read head information
590605
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')

0 commit comments

Comments
 (0)