From 96fae83e36c67f90d6c3da64a936a06a0966e981 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 17:52:42 -0400 Subject: BUG: Fix is_cygwin_git to return True on Cygwin. --- git/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index 11139156..e55f15d3 100644 --- a/git/util.py +++ b/git/util.py @@ -377,7 +377,9 @@ def is_cygwin_git(git_executable: PathLike) -> bool: def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: - if not is_win: + if is_win: + # is_win seems to be true only for Windows-native pythons + # cygwin has os.name = posix, I think return False if git_executable is None: -- cgit v1.2.1 From 3fc07acfc9a9824307cf1c41c5bfa4ed7f760f50 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:13:06 -0400 Subject: 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. --- git/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index e55f15d3..6a4a6557 100644 --- a/git/util.py +++ b/git/util.py @@ -310,7 +310,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str: else: p = cygpath(p) elif drive: - p = "/cygdrive/%s/%s" % (drive.lower(), p) + p = "/proc/cygdrive/%s/%s" % (drive.lower(), p) p_str = str(p) # ensure it is a str and not AnyPath return p_str.replace("\\", "/") @@ -334,7 +334,7 @@ def cygpath(path: str) -> str: """Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment.""" path = str(path) # ensure is str and not AnyPath. # Fix to use Paths when 3.5 dropped. or to be just str if only for urls? - if not path.startswith(("/cygdrive", "//")): + if not path.startswith(("/cygdrive", "//", "/proc/cygdrive")): for regex, parser, recurse in _cygpath_parsers: match = regex.match(path) if match: @@ -348,7 +348,7 @@ def cygpath(path: str) -> str: return path -_decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?") +_decygpath_regex = re.compile(r"(?:/proc)?/cygdrive/(\w)(/.*)?") def decygpath(path: PathLike) -> str: -- cgit v1.2.1