From 7ab12b403207bb46199f46d5aaa72d3e82a3080d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 29 Jul 2015 18:29:03 +0200 Subject: fix(index):allow adding non-unicode paths to index This issue only surfaced in python 2, in case paths containing unicode characters were not actual unicode objects. In python 3, this was never the issue. Closes #331 --- git/index/fun.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'git/index/fun.py') diff --git a/git/index/fun.py b/git/index/fun.py index 9ae46861..c1026fd6 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -41,7 +41,8 @@ from gitdb.base import IStream from gitdb.typ import str_tree_type from git.compat import ( defenc, - force_text + force_text, + force_bytes ) S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule @@ -124,7 +125,7 @@ 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) + path = force_bytes(path, encoding=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 -- cgit v1.2.1