summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
Diffstat (limited to 'git')
-rw-r--r--git/remote.py13
-rw-r--r--git/test/test_remote.py3
-rw-r--r--git/util.py32
3 files changed, 14 insertions, 34 deletions
diff --git a/git/remote.py b/git/remote.py
index 6a15c9c4..4baa2838 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -568,7 +568,12 @@ class Remote(LazyMixin, Iterable):
# end
# We are only interested in stderr here ...
- finalize_process(proc)
+ try:
+ finalize_process(proc)
+ except Exception:
+ if len(fetch_info_lines) == 0:
+ raise
+ # end exception handler
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
@@ -601,7 +606,11 @@ class Remote(LazyMixin, Iterable):
# END exception handling
# END for each line
- handle_process_output(proc, stdout_handler, progress_handler, finalize_process)
+ try:
+ handle_process_output(proc, stdout_handler, progress_handler, finalize_process)
+ except Exception:
+ if len(output) == 0:
+ raise
return output
def fetch(self, refspec=None, progress=None, **kwargs):
diff --git a/git/test/test_remote.py b/git/test/test_remote.py
index 8500a295..c419ecee 100644
--- a/git/test/test_remote.py
+++ b/git/test/test_remote.py
@@ -313,8 +313,7 @@ class TestRemote(TestBase):
self._do_test_push_result(res, remote)
# invalid refspec
- res = remote.push("hellothere")
- assert len(res) == 0
+ self.failUnlessRaises(GitCommandError, remote.push, "hellothere")
# push new tags
progress = TestRemoteProgress()
diff --git a/git/util.py b/git/util.py
index f41f20fb..1147cb53 100644
--- a/git/util.py
+++ b/git/util.py
@@ -16,10 +16,7 @@ import threading
# NOTE: Some of the unused imports might be used/imported by others.
# Handle once test-cases are back up and running.
-from .exc import (
- GitCommandError,
- InvalidGitRepositoryError
-)
+from .exc import InvalidGitRepositoryError
from .compat import (
MAXSIZE,
@@ -154,32 +151,7 @@ def get_user_id():
def finalize_process(proc):
"""Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
- try:
- proc.wait()
- except GitCommandError:
- # if a push has rejected items, the command has non-zero return status
- # a return status of 128 indicates a connection error - reraise the previous one
- # Everything else will still be parsed and made available through PushInfo flags
- # Estimated error results look like this:
- # ```bash
- # To /var/folders/xp/m48gs2tx2vg95tmtzw7tprs40000gn/T/tmpk5jeBeremote_repo_test_base
- # ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward)
- # Done
- # error: failed to push some refs to
- # '/var/folders/xp/m48gs2tx2vg95tmtzw7tprs40000gn/T/tmpk5jeBeremote_repo_test_base'
- # hint: Updates were rejected because the tip of your current branch is behind
- # hint: its remote counterpart. Integrate the remote changes (e.g.
- # hint: 'git pull ...') before pushing again.
- # hint: See the 'Note about fast-forwards' in 'git push --help' for details.
- # ```
- # See https://github.com/gitpython-developers/GitPython/blob/master/git/test/test_remote.py#L305
- # on how to check for these kinds of errors.
- # Also see this issue for a reason for this verbosity:
- # https://github.com/gitpython-developers/GitPython/issues/271
- if proc.poll() == 128:
- raise
- pass
- # END exception handling
+ proc.wait()
#} END utilities