Skip to content

Cannot add utf8 path to repository  #331

Closed
@albbas

Description

@albbas

Running the code below on a Linux machine with PythonGit 1.0.1 fails, but works with PythonGit 0.3.2 RC1

Python version: 2.7.10

Output when using PythonGit 1.0.1:
1.0.1
Traceback (most recent call last):
File "corpustools/test/test_git.py", line 11, in
r.index.add(['ø.txt'])
File "/usr/local/lib/python2.7/dist-packages/git/index/base.py", line 780, in add
self.write(ignore_extension_data=not write_extension_data)
File "/usr/local/lib/python2.7/dist-packages/git/index/base.py", line 213, in write
self._serialize(stream, ignore_extension_data)
File "/usr/local/lib/python2.7/dist-packages/git/index/base.py", line 180, in _serialize
write_cache(entries, stream, extension_data)
File "/usr/local/lib/python2.7/dist-packages/git/index/fun.py", line 132, in write_cache
write(path.encode(defenc))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

Output when using PythonGit 0.3.2 RC1
0.3.2 RC1

This is the version that is installed by the distribution (Kubuntu 15.10)

# -*- coding:utf-8 -*-
import git
import testfixtures

print git.__version__

tempdir = testfixtures.TempDirectory(ignore=['.git'])
tempdir.makedir('orig/smj/ficti/sub')
tempdir.write('orig/smj/ficti/sub/ø.txt', 'content of ø')

r = git.Repo.init(tempdir.path)
r.index.add(['orig'])
r.index.commit('Added orig and prestable')

tempdir.cleanup()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions