summaryrefslogtreecommitdiff
path: root/git/index/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-07-20 08:51:41 +0200
committerSebastian Thiel <byronimo@gmail.com>2015-07-20 09:20:00 +0200
commit9c272abea2c837e4725c37f5c0467f83f3700cd5 (patch)
tree1f55edfb7cfe0464b22808bf80990e1aea712101 /git/index/base.py
parentaf44258fa472a14ff25b4715f1ab934d177bf1fa (diff)
downloadgitpython-9c272abea2c837e4725c37f5c0467f83f3700cd5.tar.gz
fix(encoding): in untracked_files() and index
* untracked_files could, if there were spaces in the path returned, re-rencode the previously decoded unicode string thanks to a `decode("string_escape")` call. Now re-encode into utf-8 afterwards - added test to assure this works indeed * IndexFile.add() didn't handle unicode correctly and would write broken index files. The solution was to compute the path length after encoding it into utf-8 bytes, not before ... . Closes #320
Diffstat (limited to 'git/index/base.py')
-rw-r--r--git/index/base.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/git/index/base.py b/git/index/base.py
index b955dae4..4317d46a 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -583,7 +583,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
stream = None
if S_ISLNK(st.st_mode):
# in PY3, readlink is string, but we need bytes. In PY2, it's just OS encoded bytes, we assume UTF-8
- stream = BytesIO(force_bytes(os.readlink(filepath), encoding='utf-8'))
+ stream = BytesIO(force_bytes(os.readlink(filepath), encoding=defenc))
else:
stream = open(filepath, 'rb')
# END handle stream
@@ -610,7 +610,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
blob = Blob(self.repo, Blob.NULL_BIN_SHA,
stat_mode_to_index_mode(os.stat(abspath).st_mode),
- to_native_path_linux(gitrelative_path))
+ to_native_path_linux(gitrelative_path), encoding=defenc)
# TODO: variable undefined
entries.append(BaseIndexEntry.from_blob(blob))
# END for each path