Skip to content

Commit b0be02e

Browse files
committed
fix(remote): remove assertion in favour of runtime stability
Fixes #442
1 parent bed4630 commit b0be02e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: git/remote.py

+11-4
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,
@@ -35,6 +33,9 @@
3533
from git.cmd import handle_process_output
3634
from gitdb.util import join
3735
from git.compat import defenc
36+
import logging
37+
38+
log = logging.getLogger('git.remote')
3839

3940

4041
__all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote')
@@ -570,10 +571,16 @@ def _get_fetch_info_from_stderr(self, proc, progress):
570571
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
571572
fp.close()
572573

573-
# NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it.
574574
l_fil = len(fetch_info_lines)
575575
l_fhi = len(fetch_head_info)
576-
assert l_fil >= l_fhi, "len(%s) <= len(%s)" % (l_fil, l_fhi)
576+
if l_fil >= l_fhi:
577+
msg = "Fetch head does not contain enough lines to match with progress information\n"
578+
msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n"
579+
msg += "Will ignore extra progress lines."
580+
msg %= (l_fil, l_fhi)
581+
log.warn(msg)
582+
fetch_info_lines = fetch_info_lines[:l_fhi]
583+
# end sanity check + sanitization
577584

578585
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
579586
for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))

0 commit comments

Comments
 (0)