summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Scott <barry@barrys-emacs.org>2016-05-29 13:34:35 +0100
committerBarry Scott <barry@barrys-emacs.org>2016-05-29 13:34:35 +0100
commit5077fc7e4031e53f730676df4d8df5165b1d36cc (patch)
treec321d6b7340b28fd69daae860702e00d2ac0a02f
parente836e5cdcc7e3148c388fe8c4a1bab7eeb00cc3f (diff)
downloadgitpython-5077fc7e4031e53f730676df4d8df5165b1d36cc.tar.gz
Return all the stderr messge after an error is detected for pull()
-rw-r--r--git/cmd.py6
-rw-r--r--git/remote.py19
2 files changed, 20 insertions, 5 deletions
diff --git a/git/cmd.py b/git/cmd.py
index c29e3485..821bf299 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -307,7 +307,7 @@ class Git(LazyMixin):
def __getattr__(self, attr):
return getattr(self.proc, attr)
- def wait(self, stderr=None):
+ def wait(self, stderr=''):
"""Wait for the process and return its status code.
:param stderr: Previously read value of stderr, in case stderr is already closed.
@@ -317,7 +317,7 @@ class Git(LazyMixin):
def read_all_from_possibly_closed_stream(stream):
try:
- return stream.read()
+ return stderr + stream.read()
except ValueError:
return stderr or ''
@@ -678,7 +678,7 @@ class Git(LazyMixin):
# strip trailing "\n"
if stderr_value.endswith(b"\n"):
stderr_value = stderr_value[:-1]
- status = proc.wait()
+ status = proc.wait(stderr=stderr_value)
# END stdout handling
finally:
proc.stdout.close()
diff --git a/git/remote.py b/git/remote.py
index 30e32ae3..f23f50a2 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -570,11 +570,16 @@ class Remote(LazyMixin, Iterable):
progress_handler = progress.new_message_handler()
+ error_message = None
+ stderr_text = None
+
for line in proc.stderr:
line = force_text(line)
for pline in progress_handler(line):
if line.startswith('fatal:') or line.startswith('error:'):
- raise GitCommandError(("Error when fetching: %s" % line,), 2)
+ error_message = "Error when fetching: %s" % (line,)
+ break
+
# END handle special messages
for cmd in cmds:
if len(line) > 1 and line[0] == ' ' and line[1] == cmd:
@@ -582,9 +587,19 @@ class Remote(LazyMixin, Iterable):
continue
# end find command code
# end for each comand code we know
+
+ if error_message is not None:
+ break
# end for each line progress didn't handle
+
+ if error_message is not None:
+ stderr_text = proc.stderr.read()
+
# end
- finalize_process(proc)
+ finalize_process(proc, stderr=stderr_text)
+
+ if error_message is not None:
+ raise GitCommandError( error_message, 2, stderr=stderr_text )
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')