[meld] Fix some Git path handling on Windows



commit f72c0fe6513147a8634f12b71032584c106dcc10
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Jul 8 18:36:20 2012 +1000

    Fix some Git path handling on Windows
    
    Git on Windows returns unix-style path names, which causes many issues
    when we combine them with native Windows-style path names later on.
    This commit normalises returned path names in the Git module when on
    Windows, so that in theory VC status works for Git now.

 meld/vc/git.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index f424ea0..bc13493 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -68,6 +68,8 @@ class Vc(_vc.CachedVc):
     def revert_command(self):
         return [self.CMD,"checkout"]
     def valid_repo(self):
+        # TODO: On Windows, this exit code is wrong under the normal shell; it
+        # appears to be correct under the default git bash shell however.
         if _vc.call([self.CMD, "branch"], cwd=self.root):
             return False
         else:
@@ -132,6 +134,9 @@ class Vc(_vc.CachedVc):
             # There are 1 or more modified files, parse their state
             for entry in entries:
                 statekey, name = entry.split("\t", 2)
+                if os.name == 'nt':
+                    # Git returns unix-style paths on Windows
+                    name = os.path.normpath(name.strip())
                 path = os.path.join(self.root, name.strip())
                 state = self.state_map.get(statekey.strip(), _vc.STATE_NONE)
                 tree_state[path] = state



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]