Web lists-archives.com

Re: Cygwin Git with Windows paths




On Sun, Nov 18, 2018 at 07:21:58AM -0800, Steven Penny wrote:
> Cygwin programs can handle Unix form paths:
> 
>    $ ls /var
>    cache  lib  log  run  tmp
> 
> and also Windows form paths:
> 
>    $ ls 'C:\cygwin64\var'
>    cache  lib  log  run  tmp
> 
> However current Cygwin Git cannot:
> 
>    $ git clone git://github.com/benhoyt/goawk 'C:\cygwin64\tmp\goawk'
>    Cloning into 'C:\cygwin64\tmp\goawk'...
>    fatal: Invalid path '/home/Steven/C:\cygwin64\tmp\goawk': No such file or
>    directory
> 
> It seems the problem is that Git thinks the Windows form path is relative
> because it does not start with "/". A Git Bisect reveals this:
> 
> 05b458c104708141d2fad211d79703b3b99cc5a8 is the first bad commit
> commit 05b458c104708141d2fad211d79703b3b99cc5a8
> Author: Brandon Williams <bmwill@xxxxxxxxxx>
> Date:   Mon Dec 12 10:16:52 2016 -0800
> 
>    real_path: resolve symlinks by hand
> 
>    The current implementation of real_path uses chdir() in order to resolve
>    symlinks.  Unfortunately this isn't thread-safe as chdir() affects a
>    process as a whole and not just an individual thread.  Instead perform
>    the symlink resolution by hand so that the calls to chdir() can be
>    removed, making real_path one step closer to being reentrant.
> 
>    Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx>
>    Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
> 
> This causes problems for any non-Cygwin tools that might call Git:
> 
> http://github.com/golang/go/issues/23155
> 

Thanks for the report
It seams as if "C:" is not recognized as an absolute path under
cygwin.
May be it should ?

Does the following help ? (fully untested)


diff --git a/compat/cygwin.h b/compat/cygwin.h
index 8e52de4644..12814e1edb 100644
--- a/compat/cygwin.h
+++ b/compat/cygwin.h
@@ -1,2 +1,4 @@
 int cygwin_offset_1st_component(const char *path);
 #define offset_1st_component cygwin_offset_1st_component
+#define has_dos_drive_prefix(path) \
+       (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)