[meld] vc.git: Handle Unicode filenames in a git tree correctly
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] vc.git: Handle Unicode filenames in a git tree correctly
- Date: Sat, 11 Oct 2014 21:38:23 +0000 (UTC)
commit d79052457e94e26610b4f2443747fb2eb80bd3e4
Author: Hasan Arous <arous hasan gmail com>
Date: Thu Aug 7 15:03:13 2014 +0300
vc.git: Handle Unicode filenames in a git tree correctly
Correctly save and retrieve files state and meta in a Git tree.
meld/vc/git.py | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index 209ab65..b919833 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -340,6 +340,15 @@ class Vc(_vc.CachedVc):
if os.name == 'nt':
# Git returns unix-style paths on Windows
name = os.path.normpath(name.strip())
+
+ # Unicode file names are returned by git as enquoted strings, example:
+ # $ git diff-files
+ # :100644 100644 <cut> M a.txt
+ # :100644 100644 <cut> M "\330\271.txt"
+ # So we docede them back to prober python strings
+ if '"' == name[0]:
+ name = name[1:-1].decode('string_escape')
+
path = os.path.join(self.root, name.strip())
path = os.path.abspath(path)
state = self.state_map.get(statekey.strip(), _vc.STATE_NONE)
@@ -376,8 +385,9 @@ class Vc(_vc.CachedVc):
retfiles = []
retdirs = []
for name, path in files:
- state = tree.get(path, _vc.STATE_NORMAL)
- meta = self._tree_meta_cache.get(path, "")
+ # Inside python dictionaries, keys are stored as utf8 strings.
+ state = tree.get(path.encode('utf8'), _vc.STATE_NORMAL)
+ meta = self._tree_meta_cache.get(path.encode('utf8'), "")
retfiles.append(_vc.File(path, name, state, options=meta))
for name, path in dirs:
state = tree.get(path, _vc.STATE_NORMAL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]