Skip to content

Commit

Permalink
Reimplement git filesystem charset handling
Browse files Browse the repository at this point in the history
Make use of the new encoding handling implemented in the
`PyGit.Storage`. So now Trac should always get pathnames as unicode
objects.

A new TracIni option `git_fs_encoding` can be used to change the
default utf8 encoding.

This implementation assumes `from_unicode(to_unicode(.))` to be an
identity function.
  • Loading branch information
hvr committed Oct 17, 2010
1 parent b93a90d commit 3517167
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tracext/git/git_fs.py
Expand Up @@ -163,6 +163,9 @@ def get_link_resolvers(self):
"use git-committer-author timestamp instead of git-author timestamp"
" as changeset timestamp")

_git_fs_encoding = Option('git', 'git_fs_encoding', 'utf-8',
"define charset encoding of paths within git repository")

_git_bin = PathOption('git', 'git_bin', '/usr/bin/git',
"path to git executable (relative to trac project folder!)")

Expand Down Expand Up @@ -215,6 +218,7 @@ def rlookup_uid(_):
repos = GitRepository(dir, params, self.log,
persistent_cache=self._persistent_cache,
git_bin=self._git_bin,
git_fs_encoding=self._git_fs_encoding,
shortrev_len=self._shortrev_len,
rlookup_uid=rlookup_uid,
use_committer_id=self._use_committer_id,
Expand Down Expand Up @@ -317,6 +321,7 @@ class GitRepository(Repository):
def __init__(self, path, params, log,
persistent_cache=False,
git_bin='git',
git_fs_encoding='utf-8',
shortrev_len=7,
rlookup_uid=lambda _: None,
use_committer_id=False,
Expand All @@ -331,7 +336,9 @@ def __init__(self, path, params, log,
self._use_committer_time = use_committer_time
self._use_committer_id = use_committer_id

self.git = PyGIT.StorageFactory(path, log, not persistent_cache, git_bin=git_bin).getInstance()
self.git = PyGIT.StorageFactory(path, log, not persistent_cache,
git_bin=git_bin,
git_fs_encoding=git_fs_encoding).getInstance()

Repository.__init__(self, "git:"+path, self.params, log)

Expand Down Expand Up @@ -632,7 +639,7 @@ def get_changes(self):

paths_seen.add(path)

yield (to_unicode(path), kind, action, to_unicode(p_path), p_rev)
yield path, kind, action, p_path, p_rev


def get_branches(self):
Expand Down

0 comments on commit 3517167

Please sign in to comment.