@@ -225,14 +225,17 @@ def is_exec(fpath):
225225 return progs
226226
227227
228- def _cygpath (winpath ):
228+ def _cygpath (winpath , inverse = False ):
229229 """Invokes `cygpath` cmd to parse Windoews paths."""
230230 import subprocess as sbp
231231
232232 cmd = ['cygpath' , winpath ]
233+ if inverse :
234+ cmd .insert (1 , '-w' )
233235 try :
234236 cygpath = sbp .check_output (cmd , universal_newlines = True )
235- cygpath = cygpath and cygpath [:- 1 ]
237+ if cygpath and cygpath [- 1 ] == '\n ' :
238+ cygpath = cygpath [:- 1 ]
236239 except Exception as ex :
237240 log .warning ("`cygpath.exe` failed on '%s' due to: %s"
238241 " Using winpath as it is." ,
@@ -290,7 +293,7 @@ def _cyg_regex_path(drive, path):
290293)
291294
292295
293- @lru_cache (500 ) # Sice arg required only for py3.2 backport `repoze.lru` lib.
296+ @lru_cache (500 ) # Size arg required only for py3.2 backport `repoze.lru` lib.
294297def cygpath (path ):
295298 """Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment."""
296299 for regex , parser , recurse in _cygpath_parsers :
@@ -309,20 +312,23 @@ def cygpath(path):
309312_decygpath_regex = re .compile (r"/cygdrive/(\w)(/.*)?" )
310313
311314
315+ @lru_cache (500 ) # Size arg required only for py3.2 backport `repoze.lru` lib.
312316def decygpath (path ):
313- m = _decygpath_regex .match (path )
314- if m :
315- drive , rest_path = m .groups ()
316- path = '%s:%s' % (drive .upper (), rest_path or '' )
317+ if path :
318+ winpath = _cygpath (path , inverse = True )
319+ if path [- 1 ] in '/\\ ' and winpath [- 1 ] not in '/\\ ' :
320+ winpath += '\\ '
321+ path = winpath
317322
318- return path . replace ( '/' , ' \\ ' )
323+ return path
319324
320325
321326#: Store boolean flags denoting if a specific Git executable
322327#: is from a Cygwin installation (since `cache_lru()` unsupported on PY2).
323328_is_cygwin_cache = {}
324329
325330
331+ @lru_cache (50 ) # Size arg required only for py3.2 backport `repoze.lru` lib.
326332def is_cygwin_git (git_executable ):
327333 if not is_win :
328334 return False
0 commit comments