summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2016-05-26 19:41:00 +0200
committerSebastian Thiel <byronimo@gmail.com>2016-05-26 19:41:00 +0200
commit515a6b9ccf87bd1d3f5f2edd229d442706705df5 (patch)
tree040331b258b8bbc48514ca4242b3f61553e1c02b
parent04ff96ddd0215881f72cc532adc6ff044e77ea3e (diff)
downloadgitpython-515a6b9ccf87bd1d3f5f2edd229d442706705df5.tar.gz
fix(remote): use universal_newlines for fetch/push
That way, real-time parsing of output should finally be possible. Related to #444
-rw-r--r--git/cmd.py9
-rw-r--r--git/remote.py10
2 files changed, 13 insertions, 6 deletions
diff --git a/git/cmd.py b/git/cmd.py
index bbbed62f..0c3cc8ca 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -44,7 +44,8 @@ from git.compat import (
execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output',
'with_exceptions', 'as_process', 'stdout_as_string',
- 'output_stream', 'with_stdout', 'kill_after_timeout')
+ 'output_stream', 'with_stdout', 'kill_after_timeout',
+ 'universal_newlines')
log = logging.getLogger('git.cmd')
log.addHandler(logging.NullHandler())
@@ -487,6 +488,7 @@ class Git(LazyMixin):
stdout_as_string=True,
kill_after_timeout=None,
with_stdout=True,
+ universal_newlines=False,
**subprocess_kwargs
):
"""Handles executing the command on the shell and consumes and returns
@@ -541,7 +543,9 @@ class Git(LazyMixin):
specify may not be the same ones.
:param with_stdout: If True, default True, we open stdout on the created process
-
+ :param universal_newlines:
+ if True, pipes will be opened as text, and lines are split at
+ all known line endings.
:param kill_after_timeout:
To specify a timeout in seconds for the git command, after which the process
should be killed. This will have no effect if as_process is set to True. It is
@@ -608,6 +612,7 @@ class Git(LazyMixin):
stdout=with_stdout and PIPE or open(os.devnull, 'wb'),
shell=self.USE_SHELL,
close_fds=(os.name == 'posix'), # unsupported on windows
+ universal_newlines=universal_newlines,
**subprocess_kwargs
)
except cmd_not_found_exception as err:
diff --git a/git/remote.py b/git/remote.py
index bff26459..169d4f79 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -663,8 +663,8 @@ class Remote(LazyMixin, Iterable):
else:
args = [refspec]
- proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, v=True,
- **kwargs)
+ proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False,
+ universal_newlines=True, v=True, **kwargs)
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
if hasattr(self.repo.odb, 'update_cache'):
self.repo.odb.update_cache()
@@ -682,7 +682,8 @@ class Remote(LazyMixin, Iterable):
# No argument refspec, then ensure the repo's config has a fetch refspec.
self._assert_refspec()
kwargs = add_progress(kwargs, self.repo.git, progress)
- proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, v=True, **kwargs)
+ proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True,
+ universal_newlines=True, v=True, **kwargs)
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
if hasattr(self.repo.odb, 'update_cache'):
self.repo.odb.update_cache()
@@ -707,7 +708,8 @@ class Remote(LazyMixin, Iterable):
If the operation fails completely, the length of the returned IterableList will
be null."""
kwargs = add_progress(kwargs, self.repo.git, progress)
- proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs)
+ proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True,
+ universal_newlines=True, **kwargs)
return self._get_push_info(proc, progress or RemoteProgress())
@property