Skip to content

Commit 3fc07ac

Browse files
authored
ENH: Update cygpath recodes to work with all installs
People can change the `/cygdrive` prefix for mounting Windows drives; `/` and `/mnt` are both popular. `/proc/cygdrive` is always going to have the drive letters under it.
1 parent a67862c commit 3fc07ac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git/util.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
310310
else:
311311
p = cygpath(p)
312312
elif drive:
313-
p = "/cygdrive/%s/%s" % (drive.lower(), p)
313+
p = "/proc/cygdrive/%s/%s" % (drive.lower(), p)
314314
p_str = str(p) # ensure it is a str and not AnyPath
315315
return p_str.replace("\\", "/")
316316

@@ -334,7 +334,7 @@ def cygpath(path: str) -> str:
334334
"""Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment."""
335335
path = str(path) # ensure is str and not AnyPath.
336336
# Fix to use Paths when 3.5 dropped. or to be just str if only for urls?
337-
if not path.startswith(("/cygdrive", "//")):
337+
if not path.startswith(("/cygdrive", "//", "/proc/cygdrive")):
338338
for regex, parser, recurse in _cygpath_parsers:
339339
match = regex.match(path)
340340
if match:
@@ -348,7 +348,7 @@ def cygpath(path: str) -> str:
348348
return path
349349

350350

351-
_decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?")
351+
_decygpath_regex = re.compile(r"(?:/proc)?/cygdrive/(\w)(/.*)?")
352352

353353

354354
def decygpath(path: PathLike) -> str:

0 commit comments

Comments
 (0)