summaryrefslogtreecommitdiff
path: root/git/util.py
diff options
context:
space:
mode:
authorUri Baghin <uri@canva.com>2019-09-28 19:29:57 +1000
committerSebastian Thiel <sebastian.thiel@icloud.com>2019-09-30 06:57:13 +0200
commitb207f0e8910a478ad5aba17d19b2b00bf2cd9684 (patch)
tree2ed16a254655e180623c5c3ec53f1a0f2d9ea9b9 /git/util.py
parent9121f629d43607f3827c99b5ea0fece356080cf0 (diff)
downloadgitpython-b207f0e8910a478ad5aba17d19b2b00bf2cd9684.tar.gz
Remove control character stripping.
Diffstat (limited to 'git/util.py')
-rw-r--r--git/util.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/git/util.py b/git/util.py
index 7c07b0f3..aee1a44b 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 @@ class RemoteProgress(object):
# 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)