diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-07-20 08:51:41 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-07-20 09:20:00 +0200 |
commit | 9c272abea2c837e4725c37f5c0467f83f3700cd5 (patch) | |
tree | 1f55edfb7cfe0464b22808bf80990e1aea712101 /git/index/fun.py | |
parent | af44258fa472a14ff25b4715f1ab934d177bf1fa (diff) | |
download | gitpython-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/fun.py')
-rw-r--r-- | git/index/fun.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/git/index/fun.py b/git/index/fun.py index c1188ccb..9ae46861 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -124,12 +124,13 @@ def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1 write(entry[4]) # ctime write(entry[5]) # mtime path = entry[3] + path = path.encode(defenc) plen = len(path) & CE_NAMEMASK # path length assert plen == len(path), "Path %s too long to fit into index" % entry[3] flags = plen | (entry[2] & CE_NAMEMASK_INV) # clear possible previous values write(pack(">LLLLLL20sH", entry[6], entry[7], entry[0], entry[8], entry[9], entry[10], entry[1], flags)) - write(path.encode(defenc)) + write(path) real_size = ((tell() - beginoffset + 8) & ~7) write(b"\0" * ((beginoffset + real_size) - tell())) # END for each entry |