From 1fe5bd0fe45be7bafc5e7b546de3a3733cb97eb1 Mon Sep 17 00:00:00 2001 From: Uri Baghin Date: Sat, 28 Sep 2019 19:29:57 +1000 Subject: [PATCH 1/3] Remove control character stripping. --- git/util.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/git/util.py b/git/util.py index 7c07b0f3d..aee1a44b6 100644 --- a/git/util.py +++ b/git/util.py @@ -364,6 +364,7 @@ class RemoteProgress(object): '_seen_ops', 'error_lines', # Lines that started with 'error:' or 'fatal:'. 'other_lines') # Lines not denoting progress (i.e.g. push-infos). + re_ansi_escape = re.compile(r'\x1B[@-_][0-?]*[ -/]*[@-~]') re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)") re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)") @@ -392,17 +393,8 @@ def _parse_progress_line(self, line): # find escape characters and cut them away - regex will not work with # them as they are non-ascii. As git might expect a tty, it will send them - last_valid_index = None - for i, c in enumerate(reversed(line)): - if ord(c) < 32: - # its a slice index - last_valid_index = -i - 1 - # END character was non-ascii - # END for each character in line - if last_valid_index is not None: - line = line[:last_valid_index] - # END cut away invalid part - line = line.rstrip() + line = self.re_ansi_escape.sub('', line) + line.strip() cur_count, max_count = None, None match = self.re_op_relative.match(line) From b43a3edde87266e7d62a62e82fbf17204f832e56 Mon Sep 17 00:00:00 2001 From: Uri Baghin Date: Mon, 30 Sep 2019 10:21:57 +1000 Subject: [PATCH 2/3] Update util.py --- git/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index aee1a44b6..c60de71b1 100644 --- a/git/util.py +++ b/git/util.py @@ -394,7 +394,7 @@ def _parse_progress_line(self, line): # find escape characters and cut them away - regex will not work with # them as they are non-ascii. As git might expect a tty, it will send them line = self.re_ansi_escape.sub('', line) - line.strip() + line = line.strip() cur_count, max_count = None, None match = self.re_op_relative.match(line) From 7a5de476aa27d18f4adaa81f3631f37178e94db2 Mon Sep 17 00:00:00 2001 From: Uri Baghin Date: Mon, 30 Sep 2019 10:35:04 +1000 Subject: [PATCH 3/3] Update util.py --- git/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index c60de71b1..936789cbf 100644 --- a/git/util.py +++ b/git/util.py @@ -394,7 +394,7 @@ def _parse_progress_line(self, line): # find escape characters and cut them away - regex will not work with # them as they are non-ascii. As git might expect a tty, it will send them line = self.re_ansi_escape.sub('', line) - line = line.strip() + line = line.rstrip() cur_count, max_count = None, None match = self.re_op_relative.match(line)