@@ -349,6 +349,8 @@ class Remote(LazyMixin, Iterable):
349
349
__slots__ = ("repo" , "name" , "_config_reader" )
350
350
_id_attribute_ = "name"
351
351
352
+ _re_find_info = re .compile (r'\b(\S+)\s+->\s' )
353
+
352
354
def __init__ (self , repo , name ):
353
355
"""Initialize a remote instance
354
356
@@ -513,6 +515,9 @@ def _get_fetch_info_from_stderr(self, proc, progress):
513
515
# this also waits for the command to finish
514
516
# Skip some progress lines that don't provide relevant information
515
517
fetch_info_lines = list ()
518
+ # NOTE: We only keep this information for an assertion, which might as well go away.
519
+ # Implementation based on https://github.com/gitpython-developers/GitPython/pull/143
520
+ seen_refs = set ()
516
521
for line in digest_process_messages (proc .stderr , progress ):
517
522
if line .startswith ('From' ) or line .startswith ('remote: Total' ) or line .startswith ('POST' ) \
518
523
or line .startswith (' =' ):
@@ -523,6 +528,9 @@ def _get_fetch_info_from_stderr(self, proc, progress):
523
528
elif line .startswith ('fatal:' ):
524
529
raise GitCommandError (("Error when fetching: %s" % line ,), 2 )
525
530
# END handle special messages
531
+ ref = self ._re_find_info .search (line )
532
+ if ref :
533
+ seen_refs .add (ref .group (1 ))
526
534
fetch_info_lines .append (line )
527
535
# END for each line
528
536
@@ -535,6 +543,8 @@ def _get_fetch_info_from_stderr(self, proc, progress):
535
543
# I simply couldn't stand it anymore, so here is the quick and dirty fix ... .
536
544
# This project needs a lot of work !
537
545
# assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines)
546
+ assert len (seen_refs ) == len (fetch_head_info ), "len(%s) != len(%s)" % (fetch_head_info , seen_refs )
547
+
538
548
539
549
output .extend (FetchInfo ._from_line (self .repo , err_line , fetch_line )
540
550
for err_line , fetch_line in zip (fetch_info_lines , fetch_head_info ))
0 commit comments