From 1537aabfa3bb32199e321766793c87864f36ee9a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 25 May 2016 18:11:32 +0200 Subject: 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 --- git/remote.py | 14 +++++++++----- 1 file 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 -- cgit v1.2.1