diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-13 15:35:51 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-14 17:43:17 +0200 |
commit | e6e23ed24b35c6154b4ee0da5ae51cd5688e5e67 (patch) | |
tree | 173563f1efb1686ae6ac5a0a7f870cbbddc329fd /git/cmd.py | |
parent | ba7c2a0f81f83c358ae256963da86f907ca7f13c (diff) | |
download | gitpython-e6e23ed24b35c6154b4ee0da5ae51cd5688e5e67.tar.gz |
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
Diffstat (limited to 'git/cmd.py')
-rw-r--r-- | git/cmd.py | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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, @@ -191,8 +192,23 @@ class Git(LazyMixin): 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 |