summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCory Johns <cjohns@slashdotmedia.com>2013-10-09 19:02:56 +0000
committerCory Johns <cjohns@slashdotmedia.com>2013-10-09 20:49:44 +0000
commitd3a728277877924e889e9fef42501127f48a4e77 (patch)
tree930599537d72c28517b045924433f44ef7eb8da6
parent5869c5c1a51d448a411ae0d51d888793c35db9c0 (diff)
downloadgitpython-d3a728277877924e889e9fef42501127f48a4e77.tar.gz
[#5330] Ensure wait() is called on git processes
-rw-r--r--git/cmd.py1
-rw-r--r--git/objects/commit.py3
-rw-r--r--git/remote.py17
-rw-r--r--git/repo/base.py7
-rw-r--r--git/util.py12
5 files changed, 25 insertions, 15 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 63a7134e..75687a41 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -80,6 +80,7 @@ class Git(LazyMixin):
# try to kill it
try:
os.kill(self.proc.pid, 2) # interrupt signal
+ self.proc.wait() # ensure process goes away
except AttributeError:
# try windows
# for some reason, providing None for stdout/stderr still prints something. This is why
diff --git a/git/objects/commit.py b/git/objects/commit.py
index 8e74f8bf..0565b2c0 100644
--- a/git/objects/commit.py
+++ b/git/objects/commit.py
@@ -8,6 +8,7 @@ from git.util import (
Actor,
Iterable,
Stats,
+ finalize_process
)
from git.diff import Diffable
from tree import Tree
@@ -251,6 +252,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
assert len(hexsha) == 40, "Invalid line: %s" % hexsha
yield Commit(repo, hex_to_bin(hexsha))
# END for each line in stream
+ if has_attr(proc_or_stream, 'wait'):
+ finalize_process(proc_or_stream)
@classmethod
diff --git a/git/remote.py b/git/remote.py
index 5e4439fb..e38b3540 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -24,7 +24,10 @@ from refs import (
TagReference
)
-from git.util import join_path
+from git.util import (
+ join_path,
+ finalize_process
+ )
from gitdb.util import join
import re
@@ -58,18 +61,6 @@ def digest_process_messages(fh, progress):
# END while file is not done reading
return dropped_lines
-def finalize_process(proc):
- """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
- try:
- proc.wait()
- except GitCommandError,e:
- # 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
- if proc.poll() == 128:
- raise
- pass
- # END exception handling
-
def add_progress(kwargs, git, progress):
"""Add the --progress flag to the given kwargs dict if supported by the
git command. If the actual progress in the given progress instance is not
diff --git a/git/repo/base.py b/git/repo/base.py
index 14efabdc..0bc3c12c 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -6,7 +6,10 @@
from git.exc import InvalidGitRepositoryError, NoSuchPathError
from git.cmd import Git
-from git.util import Actor
+from git.util import (
+ Actor,
+ finalize_process
+ )
from git.refs import *
from git.index import IndexFile
from git.objects import *
@@ -14,7 +17,6 @@ from git.config import GitConfigParser
from git.remote import (
Remote,
digest_process_messages,
- finalize_process,
add_progress
)
@@ -541,6 +543,7 @@ class Repo(object):
untracked_files.append(untracked_info.replace("#\t", "").rstrip())
# END for each utracked info line
# END for each line
+ finalize_process(proc)
return untracked_files
@property
diff --git a/git/util.py b/git/util.py
index a9e87d6f..130d7762 100644
--- a/git/util.py
+++ b/git/util.py
@@ -121,6 +121,18 @@ def get_user_id():
# END get username from login
return "%s@%s" % (username, platform.node())
+def finalize_process(proc):
+ """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
+ try:
+ proc.wait()
+ except GitCommandError,e:
+ # 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
+ if proc.poll() == 128:
+ raise
+ pass
+ # END exception handling
+
#} END utilities
#{ Classes