Skip to content

Commit 3b9b4fe

Browse files
committed
Remove control character stripping.
1 parent 359a7e0 commit 3b9b4fe

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

git/util.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ class RemoteProgress(object):
364364
'_seen_ops',
365365
'error_lines', # Lines that started with 'error:' or 'fatal:'.
366366
'other_lines') # Lines not denoting progress (i.e.g. push-infos).
367+
re_ansi_escape = re.compile(r'\x1B[@-_][0-?]*[ -/]*[@-~]')
367368
re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)")
368369
re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)")
369370

@@ -395,17 +396,8 @@ def _parse_progress_line(self, line):
395396
for sline in sub_lines:
396397
# find escape characters and cut them away - regex will not work with
397398
# them as they are non-ascii. As git might expect a tty, it will send them
398-
last_valid_index = None
399-
for i, c in enumerate(reversed(sline)):
400-
if ord(c) < 32:
401-
# its a slice index
402-
last_valid_index = -i - 1
403-
# END character was non-ascii
404-
# END for each character in sline
405-
if last_valid_index is not None:
406-
sline = sline[:last_valid_index]
407-
# END cut away invalid part
408-
sline = sline.rstrip()
399+
sline = self.re_ansi_escape.sub('', sline)
400+
sline = sline.strip()
409401

410402
cur_count, max_count = None, None
411403
match = self.re_op_relative.match(sline)

0 commit comments

Comments
 (0)