diff --git a/git/cmd.py b/git/cmd.py index 1d9b4efbb..cbbd0a7ad 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -382,6 +382,11 @@ def execute(self, command, finally: proc.stdout.close() proc.stderr.close() + if proc.stdin: + proc.stdin.close() + proc.poll() + if proc.returncode is None: + proc.terminate() if self.GIT_PYTHON_TRACE == 'full': cmdstr = " ".join(command) diff --git a/git/objects/commit.py b/git/objects/commit.py index f9923e4de..e64d4da30 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -350,24 +350,31 @@ def _iter_from_process_or_stream(cls, odb, proc_or_stream): :param proc: git-rev-list process instance - one sha per line :return: iterator returning Commit objects""" stream = proc_or_stream + close_std_err = False if not hasattr(stream,'readline'): stream = proc_or_stream.stdout + close_std_err = True readline = stream.readline - while True: - line = readline() - if not line: - break - hexsha = line.strip() - if len(hexsha) > 40: - # split additional information, as returned by bisect for instance - hexsha, rest = line.split(None, 1) - # END handle extra info - - assert len(hexsha) == 40, "Invalid line: %s" % hexsha - yield cls(odb, hex_to_bin(hexsha)) - # END for each line in stream - + try: + while True: + line = readline() + if not line: + break + hexsha = line.strip() + if len(hexsha) > 40: + # split additional information, as returned by bisect for instance + hexsha, rest = line.split(None, 1) + # END handle extra info + + assert len(hexsha) == 40, "Invalid line: %s" % hexsha + yield cls(odb, hex_to_bin(hexsha)) + # END for each line in stream + finally: + stream.close() + if close_std_err: + proc_or_stream.stderr.close() + #{ Serializable Implementation def _serialize(self, stream):
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: