summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2016-05-25 18:11:32 +0200
committerSebastian Thiel <byronimo@gmail.com>2016-05-25 18:11:32 +0200
commit1537aabfa3bb32199e321766793c87864f36ee9a (patch)
tree950041849baffa67974b1fa05947d66b873b3c2c
parentb0be02e1471c99e5e5e4bd52db1019006d26c349 (diff)
downloadgitpython-1537aabfa3bb32199e321766793c87864f36ee9a.tar.gz
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
-rw-r--r--git/remote.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/git/remote.py b/git/remote.py
index 54773a6f..6a22768d 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -573,15 +573,19 @@ class Remote(LazyMixin, Iterable):
l_fil = len(fetch_info_lines)
l_fhi = len(fetch_head_info)
- if l_fil >= l_fhi:
- msg = "Fetch head does not contain enough lines to match with progress information\n"
+ if l_fil != l_fhi:
+ msg = "Fetch head lines do not match lines provided via progress information\n"
msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n"
- msg += "Will ignore extra progress lines."
+ msg += "Will ignore extra progress lines or fetch head lines."
msg %= (l_fil, l_fhi)
log.warn(msg)
- fetch_info_lines = fetch_info_lines[:l_fhi]
+ if l_fil < l_fhi:
+ fetch_head_info = fetch_head_info[:l_fil]
+ else:
+ fetch_info_lines = fetch_info_lines[:l_fhi]
+ # end truncate correct list
# end sanity check + sanitization
-
+
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))
return output