Skip to content

Commit d255f4c

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents b4492c7 + c5077da commit d255f4c

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

‎.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
language: python
22
python:
3+
- "2.6"
34
- "2.7"
45
- "3.3"
56
- "3.4"
67
- "3.5"
78
# - "pypy" - won't work as smmap doesn't work (see gitdb/.travis.yml for details)
9+
matrix:
10+
allow_failures:
11+
- python: "2.6"
812
git:
913
# a higher depth is needed for most of the tests - must be high enough to not actually be shallow
1014
# as we clone our own repository in the process

‎doc/source/intro.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Requirements
1414
============
1515

1616
* `Python`_ 2.7 or newer
17-
Since GitPython 2.0.0
17+
Since GitPython 2.0.0. Please note that python 2.6 is still reasonably well supported, but might
18+
deteriorate over time.
1819
* `Git`_ 1.7.0 or newer
1920
It should also work with older versions, but it may be that some operations
2021
involving remotes will not work as expected.

‎git/cmd.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import errno
1414
import mmap
1515

16-
from collections import OrderedDict
16+
from git.odict import OrderedDict
1717

1818
from contextlib import contextmanager
1919
import signal
@@ -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
@@ -605,9 +609,10 @@ def execute(self, command,
605609
bufsize=-1,
606610
stdin=istream,
607611
stderr=PIPE,
608-
stdout=with_stdout and PIPE or open(os.devnull, 'wb'),
612+
stdout=PIPE if with_stdout else 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

+25-12
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
SymbolicReference,
2121
TagReference
2222
)
23-
24-
2523
from git.util import (
2624
LazyMixin,
2725
Iterable,
@@ -34,7 +32,10 @@
3432
)
3533
from git.cmd import handle_process_output
3634
from gitdb.util import join
37-
from git.compat import defenc
35+
from git.compat import (defenc, force_text)
36+
import logging
37+
38+
log = logging.getLogger('git.remote')
3839

3940

4041
__all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote')
@@ -568,8 +569,8 @@ def _get_fetch_info_from_stderr(self, proc, progress):
568569

569570
progress_handler = progress.new_message_handler()
570571

571-
for line in proc.stderr.readlines():
572-
line = line.decode(defenc)
572+
for line in proc.stderr:
573+
line = force_text(line)
573574
for pline in progress_handler(line):
574575
if line.startswith('fatal:') or line.startswith('error:'):
575576
raise GitCommandError(("Error when fetching: %s" % line,), 2)
@@ -589,11 +590,21 @@ def _get_fetch_info_from_stderr(self, proc, progress):
589590
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
590591
fp.close()
591592

592-
# NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it.
593593
l_fil = len(fetch_info_lines)
594594
l_fhi = len(fetch_head_info)
595-
assert l_fil >= l_fhi, "len(%s) <= len(%s)" % (l_fil, l_fhi)
596-
595+
if l_fil != l_fhi:
596+
msg = "Fetch head lines do not match lines provided via progress information\n"
597+
msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n"
598+
msg += "Will ignore extra progress lines or fetch head lines."
599+
msg %= (l_fil, l_fhi)
600+
log.debug(msg)
601+
if l_fil < l_fhi:
602+
fetch_head_info = fetch_head_info[:l_fil]
603+
else:
604+
fetch_info_lines = fetch_info_lines[:l_fhi]
605+
# end truncate correct list
606+
# end sanity check + sanitization
607+
597608
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
598609
for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))
599610
return output
@@ -673,8 +684,8 @@ def fetch(self, refspec=None, progress=None, **kwargs):
673684
else:
674685
args = [refspec]
675686

676-
proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False, v=True,
677-
**kwargs)
687+
proc = self.repo.git.fetch(self, *args, as_process=True, with_stdout=False,
688+
universal_newlines=True, v=True, **kwargs)
678689
res = self._get_fetch_info_from_stderr(proc, progress)
679690
if hasattr(self.repo.odb, 'update_cache'):
680691
self.repo.odb.update_cache()
@@ -692,7 +703,8 @@ def pull(self, refspec=None, progress=None, **kwargs):
692703
# No argument refspec, then ensure the repo's config has a fetch refspec.
693704
self._assert_refspec()
694705
kwargs = add_progress(kwargs, self.repo.git, progress)
695-
proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True, v=True, **kwargs)
706+
proc = self.repo.git.pull(self, refspec, with_stdout=False, as_process=True,
707+
universal_newlines=True, v=True, **kwargs)
696708
res = self._get_fetch_info_from_stderr(proc, progress)
697709
if hasattr(self.repo.odb, 'update_cache'):
698710
self.repo.odb.update_cache()
@@ -733,7 +745,8 @@ def push(self, refspec=None, progress=None, **kwargs):
733745
If the operation fails completely, the length of the returned IterableList will
734746
be null."""
735747
kwargs = add_progress(kwargs, self.repo.git, progress)
736-
proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs)
748+
proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True,
749+
universal_newlines=True, **kwargs)
737750
return self._get_push_info(proc, progress)
738751

739752
@property

0 commit comments

Comments
 (0)