summaryrefslogtreecommitdiff
path: root/git/util.py
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-14 16:43:52 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-14 17:43:18 +0200
commit3b1cfcc629e856b1384b811b8cf30b92a1e34fe1 (patch)
tree92d3d7b5a03b1626ae9aa01db0dafcd6837cd34f /git/util.py
parent57d053792d1cde6f97526d28abfae4928a61e20f (diff)
downloadgitpython-3b1cfcc629e856b1384b811b8cf30b92a1e34fe1.tar.gz
cygwin, #533: Allow '/cygdrive/c/' paths on repo init
- Cygwin TCs failing: - PY2: err: 13, fail: 2 - PY3: err: 12, fail: 2
Diffstat (limited to 'git/util.py')
-rw-r--r--git/util.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/git/util.py b/git/util.py
index b7d18023..9668f7b3 100644
--- a/git/util.py
+++ b/git/util.py
@@ -222,7 +222,7 @@ def _cygexpath(drive, path):
# It's an error, leave it alone just slashes)
p = path
else:
- p = osp.normpath(osp.expandvars(os.path.expanduser(path)))
+ p = path and osp.normpath(osp.expandvars(os.path.expanduser(path)))
if osp.isabs(p):
if drive:
# Confusing, maybe a remote system should expand vars.
@@ -278,6 +278,18 @@ def cygpath(path):
return path
+_decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?")
+
+
+def decygpath(path):
+ m = _decygpath_regex.match(path)
+ if m:
+ drive, rest_path = m.groups()
+ path = '%s:%s' % (drive.upper(), rest_path or '')
+
+ return path.replace('/', '\\')
+
+
#: Store boolean flags denoting if a specific Git executable
#: is from a Cygwin installation (since `cache_lru()` unsupported on PY2).
_is_cygwin_cache = {}