Skip to content

Commit 515a6b9

Browse files
committed
fix(remote): use universal_newlines for fetch/push
That way, real-time parsing of output should finally be possible. Related to #444
1 parent 04ff96d commit 515a6b9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

git/cmd.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444

4545
execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output',
4646
'with_exceptions', 'as_process', 'stdout_as_string',
47-
'output_stream', 'with_stdout', 'kill_after_timeout')
47+
'output_stream', 'with_stdout', 'kill_after_timeout',
48+
'universal_newlines')
4849

4950
log = logging.getLogger('git.cmd')
5051
log.addHandler(logging.NullHandler())
@@ -487,6 +488,7 @@ def execute(self, command,
487488
stdout_as_string=True,
488489
kill_after_timeout=None,
489490
with_stdout=True,
491+
universal_newlines=False,
490492
**subprocess_kwargs
491493
):
492494
"""Handles executing the command on the shell and consumes and returns
@@ -541,7 +543,9 @@ def execute(self, command,
541543
specify may not be the same ones.
542544
543545
:param with_stdout: If True, default True, we open stdout on the created process
544-
546+
:param universal_newlines:
547+
if True, pipes will be opened as text, and lines are split at
548+
all known line endings.
545549
:param kill_after_timeout:
546550
To specify a timeout in seconds for the git command, after which the process
547551
should be killed. This will have no effect if as_process is set to True. It is
@@ -608,6 +612,7 @@ def execute(self, command,
608612
stdout=with_stdout and PIPE or open(os.devnull, 'wb'),
609613
shell=self.USE_SHELL,
610614
close_fds=(os.name == 'posix'), # unsupported on windows
615+
universal_newlines=universal_newlines,
611616
**subprocess_kwargs
612617
)
613618
except cmd_not_found_exception as err:

git/remote.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@ def fetch(self, refspec=None, progress=None, **kwargs):
663663
else:
664664
args = [refspec]
665665

666-
proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, v=True,
667-
**kwargs)
666+
proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False,
667+
universal_newlines=True, v=True, **kwargs)
668668
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
669669
if hasattr(self.repo.odb, 'update_cache'):
670670
self.repo.odb.update_cache()
@@ -682,7 +682,8 @@ def pull(self, refspec=None, progress=None, **kwargs):
682682
# No argument refspec, then ensure the repo's config has a fetch refspec.
683683
self._assert_refspec()
684684
kwargs = add_progress(kwargs, self.repo.git, progress)
685-
proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, v=True, **kwargs)
685+
proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True,
686+
universal_newlines=True, v=True, **kwargs)
686687
res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
687688
if hasattr(self.repo.odb, 'update_cache'):
688689
self.repo.odb.update_cache()
@@ -707,7 +708,8 @@ def push(self, refspec=None, progress=None, **kwargs):
707708
If the operation fails completely, the length of the returned IterableList will
708709
be null."""
709710
kwargs = add_progress(kwargs, self.repo.git, progress)
710-
proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs)
711+
proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True,
712+
universal_newlines=True, **kwargs)
711713
return self._get_push_info(proc, progress or RemoteProgress())
712714

713715
@property

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy