Skip to content

Commit 3c8a33e

Browse files
committed
fix(encoding): in untracked_files()
I have no idea why PY3 requires such a mess of encoding/decoding statements, but let's just be happy it works. Also let's be sure I never ever write python code again ... EVER.
1 parent 9c272ab commit 3c8a33e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎git/repo/base.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
)
5555
from git.compat import (
5656
text_type,
57-
defenc
57+
force_text,
58+
defenc,
59+
PY3
5860
)
5961

6062
import os
@@ -625,7 +627,12 @@ def _get_untracked_files(self, **kwargs):
625627
filename = line[len(prefix):].rstrip('\n')
626628
# Special characters are escaped
627629
if filename[0] == filename[-1] == '"':
628-
filename = filename[1:-1].decode('string_escape').decode(defenc)
630+
filename = filename[1:-1]
631+
if PY3:
632+
# WHATEVER ... it's a mess, but works for me
633+
filename = filename.encode('ascii').decode('unicode_escape').encode('latin1').decode(defenc)
634+
else:
635+
filename = filename.decode('string_escape').decode(defenc)
629636
untracked_files.append(filename)
630637
finalize_process(proc)
631638
return untracked_files

0 commit comments

Comments
 (0)