Skip to content

Commit

Permalink
Fix handling of invalid utf8 filenames.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed May 1, 2017
1 parent 91ef763 commit 60b8b76
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dulwich/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,24 +452,33 @@ def test_no_decode_encode(self):

tree = Tree()
latin1_name = u'À'.encode('latin1')
latin1_path = os.path.join(repo_dir_bytes, latin1_name)
utf8_name = u'À'.encode('utf8')
utf8_path = os.path.join(repo_dir_bytes, utf8_name)
tree[latin1_name] = (stat.S_IFREG | 0o644, file.id)
tree[utf8_name] = (stat.S_IFREG | 0o644, file.id)

repo.object_store.add_objects(
[(o, None) for o in [file, tree]])

try:
os.path.exists(latin1_path)
except UnicodeDecodeError:
# This happens e.g. with python3.6 on Windows.
# It implicitly decodes using utf8, which doesn't work.
self.skipTest('can not implicitly convert as utf8')

build_index_from_tree(
repo.path, repo.index_path(),
repo.object_store, tree.id)

# Verify index entries
index = repo.open_index()
self.assertIn(latin1_name, index)
self.assertIn(utf8_name, index)

latin1_path = os.path.join(repo_dir_bytes, latin1_name)
self.assertTrue(os.path.exists(latin1_path))

utf8_path = os.path.join(repo_dir_bytes, utf8_name)
self.assertTrue(os.path.exists(utf8_path))

def test_git_submodule(self):
Expand Down

0 comments on commit 60b8b76

Please sign in to comment.