| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8324c4b commit 7ab12b4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,8 @@ | |||
| 41 | 41 | from gitdb.typ import str_tree_type | |
| 42 | 42 | from git.compat import ( | |
| 43 | 43 | defenc, | |
| 44 | - force_text | ||
| 44 | + force_text, | ||
| 45 | + force_bytes | ||
| 45 | 46 | ) | |
| 46 | 47 | ||
| 47 | 48 | S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule | |
@@ -124,7 +125,7 @@ def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1 | |||
| 124 | 125 | write(entry[4]) # ctime | |
| 125 | 126 | write(entry[5]) # mtime | |
| 126 | 127 | path = entry[3] | |
| 127 | - path = path.encode(defenc) | ||
| 128 | + path = force_bytes(path, encoding=defenc) | ||
| 128 | 129 | plen = len(path) & CE_NAMEMASK # path length | |
| 129 | 130 | assert plen == len(path), "Path %s too long to fit into index" % entry[3] | |
| 130 | 131 | flags = plen | (entry[2] & CE_NAMEMASK_INV) # clear possible previous values | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ | |||
| 18 | 18 | ) | |
| 19 | 19 | from git import ( | |
| 20 | 20 | IndexFile, | |
| 21 | + Repo, | ||
| 21 | 22 | BlobFilter, | |
| 22 | 23 | UnmergedEntriesError, | |
| 23 | 24 | Tree, | |
@@ -45,6 +46,7 @@ | |||
| 45 | 46 | IndexEntry | |
| 46 | 47 | ) | |
| 47 | 48 | from git.index.fun import hook_path | |
| 49 | + from gitdb.test.lib import with_rw_directory | ||
| 48 | 50 | ||
| 49 | 51 | ||
| 50 | 52 | class TestIndex(TestBase): | |
@@ -780,3 +782,14 @@ def test_index_bare_add(self, rw_bare_repo): | |||
| 780 | 782 | except InvalidGitRepositoryError: | |
| 781 | 783 | asserted = True | |
| 782 | 784 | assert asserted, "Adding using a filename is not correctly asserted." | |
| 785 | + | ||
| 786 | + @with_rw_directory | ||
| 787 | + def test_add_utf8P_path(self, rw_dir): | ||
| 788 | + # NOTE: fp is not a Unicode object in python 2 (which is the source of the problem) | ||
| 789 | + fp = os.path.join(rw_dir, 'ø.txt') | ||
| 790 | + with open(fp, 'w') as fs: | ||
| 791 | + fs.write('content of ø') | ||
| 792 | + | ||
| 793 | + r = Repo.init(rw_dir) | ||
| 794 | + r.index.add([fp]) | ||
| 795 | + r.index.commit('Added orig and prestable') | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments