From 4acba834e34fbf05dba00119e19a8e458f835f8b Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Thu, 5 Oct 2017 12:46:54 -0400 Subject: [PATCH] Allow user to use kill_after_timeout / as_process with clone_from The git.cmd.execute function has the ability to use the kill_after_timeout variable, however currently the clone function has as_process hardcoded to True. If progress is None, we can likley rely directly on git.cmd.execute() for process handling, which then exposes kill_after_timeout properly. Signed-off-by: Paul Belanger --- git/repo/base.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/git/repo/base.py b/git/repo/base.py index 9ed3f7141..6ac6b2d1e 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -900,8 +900,10 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, expand_vars=True, **kwa @classmethod def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): + as_process = False if progress is not None: progress = to_progress_instance(progress) + as_process = True odbt = kwargs.pop('odbt', odb_default_type) @@ -917,14 +919,10 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): sep_dir = kwargs.get('separate_git_dir') if sep_dir: kwargs['separate_git_dir'] = Git.polish_url(sep_dir) - proc = git.clone(Git.polish_url(url), clone_path, with_extended_output=True, as_process=True, - v=True, **add_progress(kwargs, git, progress)) + proc = git.clone(Git.polish_url(url), clone_path, with_extended_output=True, + as_process=as_process, v=True, **add_progress(kwargs, git, progress)) if progress: handle_process_output(proc, None, progress.new_message_handler(), finalize_process) - else: - (stdout, stderr) = proc.communicate() - log.debug("Cmd(%s)'s unused stdout: %s", getattr(proc, 'args', ''), stdout) - finalize_process(proc, stderr=stderr) # our git command could have a different working dir than our actual # environment, hence we prepend its working dir if required