From e6e23ed24b35c6154b4ee0da5ae51cd5688e5e67 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Thu, 13 Oct 2016 15:35:51 +0200 Subject: cygwin, #533: Try to make it work with Cygwin's Git. + Make `Git.polish_url()` convert paths into Cygwin-friendly paths. + Add utility and soe TCs for funcs for detecting cygwin and converting abs-paths to `/cygdrive/c/...`. - Cygwin TCs failing: - PY2: err: 14, fail: 3 - PY3: err: 13, fail: 3 --- git/cmd.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index f0757301..3fc616f5 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -31,6 +31,7 @@ from git.compat import ( ) from git.exc import CommandError from git.odict import OrderedDict +from git.util import is_cygwin_git, cygpath from .exc import ( GitCommandError, @@ -190,9 +191,24 @@ class Git(LazyMixin): # Override this value using `Git.USE_SHELL = True` USE_SHELL = False + @classmethod + def is_cygwin(cls): + return is_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE) + @classmethod def polish_url(cls, url): - return url.replace("\\\\", "\\").replace("\\", "/") + if cls.is_cygwin(): + """Remove any backslahes from urls to be written in config files. + + Windows might create config-files containing paths with backslashed, + but git stops liking them as it will escape the backslashes. + Hence we undo the escaping just to be sure. + """ + url = cygpath(url) + else: + url = url.replace("\\\\", "\\").replace("\\", "/") + + return url class AutoInterrupt(object): """Kill/Interrupt the stored process instance once this instance goes out of scope. It is -- cgit v1.2.1 From 0bce7cc4a43e5843c9f4939db143a9d92bb45a18 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Fri, 14 Oct 2016 11:24:51 +0200 Subject: cygwin, #533: FIX daemon launching + Rework git-daemon launching with `with` resource-management. + cmd: add `is_cygwin` optional override kwd on `Git.polish_url()`. - Cygwin TCs failing: - PY2: err: 13, fail: 3 - PY3: err: 12, fail: 3 --- git/cmd.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index 3fc616f5..c43fac56 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -196,16 +196,19 @@ class Git(LazyMixin): return is_cygwin_git(cls.GIT_PYTHON_GIT_EXECUTABLE) @classmethod - def polish_url(cls, url): - if cls.is_cygwin(): + def polish_url(cls, url, is_cygwin=None): + if is_cygwin is None: + is_cygwin = cls.is_cygwin() + + if is_cygwin: + url = cygpath(url) + else: """Remove any backslahes from urls to be written in config files. Windows might create config-files containing paths with backslashed, but git stops liking them as it will escape the backslashes. Hence we undo the escaping just to be sure. """ - url = cygpath(url) - else: url = url.replace("\\\\", "\\").replace("\\", "/") return url -- cgit v1.2.1