Skip to content

Commit cbb5886

Browse files
committed
Unicode: tree_to_stream can now handle unicode names the way git would do it. Its can be assumed though that there are more bugs related to unicode hanging around in the system
1 parent 33819a2 commit cbb5886

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/git/objects/fun.py

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def tree_to_stream(entries, write):
2525
mode_str = mode_str[1:]
2626
# END save a byte
2727

28+
# here it comes: if the name is actually unicode, the replacement below
29+
# will not work as the binsha is not part of the ascii unicode encoding -
30+
# hence we must convert to an utf8 string for it to work properly.
31+
# According to my tests, this is exactly what git does, that is it just
32+
# takes the input literally, which appears to be utf8 on linux.
33+
if isinstance(name, unicode):
34+
name = name.encode("utf8")
2835
write("%s %s\0%s" % (mode_str, name, binsha))
2936
# END for each item
3037

0 commit comments

Comments
 (0)