From 3b1cfcc629e856b1384b811b8cf30b92a1e34fe1 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Fri, 14 Oct 2016 16:43:52 +0200 Subject: cygwin, #533: Allow '/cygdrive/c/' paths on repo init - Cygwin TCs failing: - PY2: err: 13, fail: 2 - PY3: err: 12, fail: 2 --- git/util.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'git/util.py') 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 = {} -- cgit v1.2.1