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/test/test_index.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'git/test/test_index.py') diff --git a/git/test/test_index.py b/git/test/test_index.py index 2fd53f65..39788575 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -18,6 +18,7 @@ from git.exc import ( ) from git import ( IndexFile, + Repo, BlobFilter, UnmergedEntriesError, Tree, @@ -45,6 +46,7 @@ from git.index.typ import ( IndexEntry ) from git.index.fun import hook_path +from gitdb.test.lib import with_rw_directory class TestIndex(TestBase): @@ -780,3 +782,14 @@ class TestIndex(TestBase): except InvalidGitRepositoryError: asserted = True assert asserted, "Adding using a filename is not correctly asserted." + + @with_rw_directory + def test_add_utf8P_path(self, rw_dir): + # NOTE: fp is not a Unicode object in python 2 (which is the source of the problem) + fp = os.path.join(rw_dir, 'ø.txt') + with open(fp, 'w') as fs: + fs.write('content of ø') + + r = Repo.init(rw_dir) + r.index.add([fp]) + r.index.commit('Added orig and prestable') -- cgit v1.2.1