File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,13 @@ def tree_entries_from_data(data):
70
70
# default encoding for strings in git is utf8
71
71
# Only use the respective unicode object if the byte stream was encoded
72
72
name = data [ns :i ]
73
- name_enc = name .decode ("utf-8" )
74
- if len (name ) > len (name_enc ):
75
- name = name_enc
73
+ try :
74
+ name_enc = name .decode ("utf-8" )
75
+ except UnicodeDecodeError :
76
+ pass
77
+ else :
78
+ if len (name ) > len (name_enc ):
79
+ name = name_enc
76
80
# END handle encoding
77
81
78
82
# byte is NULL, get next 20
Original file line number Diff line number Diff line change @@ -249,3 +249,8 @@ def test_tree_traversal_single(self):
249
249
entries = traverse_tree_recursive (odb , commit .tree .binsha , '' )
250
250
assert entries
251
251
# END for each commit
252
+
253
+ def test_tree_entries_from_data ():
254
+ from git .objects .fun import tree_entries_from_data
255
+ r = tree_entries_from_data (b'100644 \x9f \0 aaa' )
256
+ assert r == [('aaa' , 33188 , '\x9f ' )], r
You can’t perform that action at this time.
0 commit comments