git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Cygwin Git with Windows paths

From
Torsten Bögershausen <tboegi@web.de>
Date
Nov 18, 2018, 15:41 UTC
Message-ID
<20181118154124.GA21680@tor.lan>
In-Reply-To
<5bf18396.1c69fb81.20780.2b1d@mx.google.com>
On Sun, Nov 18, 2018 at 07:21:58AM -0800, Steven Penny wrote:
Show 40 quoted lines
> 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@google.com>
> 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@google.com>
>    Signed-off-by: Junio C Hamano <gitster@pobox.com>
> 
> 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)
Previous: Steven PennyNext: Steven Penny
Message 2 of 56 in “Cygwin Git with Windows paths”
  1. Steven PennyNov 18, 2018
  2. Torsten BögershausenNov 18, 2018
  3. Steven PennyNov 18, 2018
  4. Torsten BögershausenNov 18, 2018
  5. Steven PennyNov 18, 2018
  6. Torsten BögershausenNov 18, 2018
  7. Steven PennyNov 18, 2018
  8. Junio C HamanoNov 19, 2018
  9. Randall S. BeckerNov 19, 2018
  10. Junio C HamanoNov 19, 2018
  11. Torsten BögershausenNov 19, 2018
  12. Steven PennyNov 20, 2018
  13. Torsten BögershausenNov 20, 2018
  14. Steven PennyNov 20, 2018
  15. Randall S. BeckerNov 19, 2018
  16. 1/1 'git clone <url> C:\cygwin\home\USER\repo' is working (again)tboegi@web.de, Nov 26, 2018
  17. Steven PennyNov 27, 2018
  18. Junio C HamanoNov 27, 2018
  19. Steven PennyNov 27, 2018
  20. Junio C HamanoNov 27, 2018
  21. Steven PennyNov 27, 2018
  22. Johannes SchindelinNov 27, 2018
  23. Junio C HamanoNov 28, 2018
  24. J.H. van de WaterNov 28, 2018
  25. Johannes SchindelinNov 28, 2018
  26. HouderNov 28, 2018
  27. Johannes SchindelinNov 28, 2018
  28. Achim GratzNov 27, 2018
  29. Johannes SchindelinNov 27, 2018
  30. Junio C HamanoNov 28, 2018
  31. Achim GratzNov 27, 2018
  32. 2/3 offset_1st_component(), dos_drive_prefix() return size_ttboegi@web.de, Dec 7, 2018
  33. 1/3 git clone <url> C:\cygwin\home\USER\repo' is working (again)tboegi@web.de, Dec 7, 2018
  34. Johannes SchindelinDec 7, 2018
  35. Steven PennyDec 8, 2018
  36. Johannes SchindelinDec 10, 2018
  37. Steven PennyDec 10, 2018
  38. Johannes SchindelinDec 11, 2018
  39. Steven PennyDec 12, 2018
  40. Johannes SixtDec 12, 2018
  41. Steven PennyDec 12, 2018
  42. Junio C HamanoDec 13, 2018
  43. Johannes SchindelinDec 12, 2018
  44. Elijah NewrenDec 12, 2018
  45. Johannes SchindelinDec 12, 2018
  46. 3/3 Refactor mingw_cygwin_offset_1st_component()tboegi@web.de, Dec 7, 2018
  47. Johannes SchindelinDec 7, 2018
  48. 1/1 git clone <url> C:\cygwin\home\USER\repo' is working (again)tboegi@web.de, Dec 8, 2018
  49. Steven PennyDec 8, 2018
  50. Junio C HamanoDec 9, 2018
  51. Johannes SchindelinDec 10, 2018
  52. Torsten BögershausenDec 11, 2018
  53. Johannes SchindelinDec 11, 2018
  54. Torsten BögershausenDec 11, 2018
  55. 1/1 git clone <url> C:\cygwin\home\USER\repo' is working (again)tboegi@web.de, Dec 15, 2018
  56. Achim GratzMay 2, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.