Skip to content

Commit 1537aab

Browse files
committed
fix(remote): better array truncation logic
Previously, the logic was not correct. Now it should work either way, truncating the correct list to assure both always have the same length. Related to #442
1 parent b0be02e commit 1537aab

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎git/remote.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,19 @@ def _get_fetch_info_from_stderr(self, proc, progress):
573573

574574
l_fil = len(fetch_info_lines)
575575
l_fhi = len(fetch_head_info)
576-
if l_fil >= l_fhi:
577-
msg = "Fetch head does not contain enough lines to match with progress information\n"
576+
if l_fil != l_fhi:
577+
msg = "Fetch head lines do not match lines provided via progress information\n"
578578
msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n"
579-
msg += "Will ignore extra progress lines."
579+
msg += "Will ignore extra progress lines or fetch head lines."
580580
msg %= (l_fil, l_fhi)
581581
log.warn(msg)
582-
fetch_info_lines = fetch_info_lines[:l_fhi]
582+
if l_fil < l_fhi:
583+
fetch_head_info = fetch_head_info[:l_fil]
584+
else:
585+
fetch_info_lines = fetch_info_lines[:l_fhi]
586+
# end truncate correct list
583587
# end sanity check + sanitization
584-
588+
585589
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
586590
for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))
587591
return output

0 commit comments

Comments
 (0)