diff --git a/git/cmd.py b/git/cmd.py index 576a5300a..1276efa40 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -5,6 +5,7 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os, sys +import tempfile from util import ( LazyMixin, stream_copy @@ -234,7 +235,15 @@ def _set_cache_(self, attr): if attr == '_version_info': # We only use the first 4 numbers, as everthing else could be strings in fact (on windows) version_numbers = self._call_process('version').split(' ')[2] - self._version_info = tuple(int(n) for n in version_numbers.split('.')[:4]) + ver_list = version_numbers.split('.') + version_info = list() + for n_str in ver_list: + try: + n_int = int(n_str) + version_info.append(n_int) + except ValueError: + pass + self._version_info = tuple(n for n in version_info) else: super(Git, self)._set_cache_(attr) #END handle version info @@ -328,19 +337,30 @@ def execute(self, command, cwd = os.getcwd() else: cwd=self._working_dir - + + if as_process: + temp_file_err = tempfile.TemporaryFile() + temp_file_out = tempfile.TemporaryFile() + stderr_pipe=temp_file_err.fileno() + stdout_pipe=temp_file_out.fileno() + else: + stderr_pipe=PIPE + stdout_pipe=PIPE + # Start the process proc = Popen(command, - cwd=cwd, - stdin=istream, - stderr=PIPE, - stdout=PIPE, - close_fds=(os.name=='posix'),# unsupported on linux - **subprocess_kwargs - ) + cwd=cwd, + stdin=istream, + stderr=stderr_pipe, + stdout=stdout_pipe, + close_fds=(os.name=='posix'),# unsupported on linux + **subprocess_kwargs + ) if as_process: + proc.stderr = temp_file_err + proc.stdout = temp_file_out return self.AutoInterrupt(proc, command) - + # Wait for the process to return status = 0 stdout_value = '' diff --git a/git/remote.py b/git/remote.py index ed01783ca..6462b1c90 100644 --- a/git/remote.py +++ b/git/remote.py @@ -513,8 +513,11 @@ def update(self, **kwargs): def _get_fetch_info_from_stderr(self, proc, progress): # skip first line as it is some remote info we are not interested in output = IterableList('name') - - + + finalize_process(proc) + proc.stderr.seek(0) + proc.stdout.seek(0) + # lines which are no progress are fetch info lines # this also waits for the command to finish # Skip some progress lines that don't provide relevant information