{"thread":{"id":"49846","subject":"Cygwin Git with Windows paths","startedAt":"2018-11-18T15:24:10Z","lastAt":"2019-05-02T07:49:11Z","messageCount":56,"participants":["Steven Penny","Torsten Bögershausen","Junio C Hamano","Randall S. Becker","tboegi@web.de","Johannes Schindelin","Achim Gratz","J.H. van de Water","Houder","Elijah Newren","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"363579","messageId":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","threadId":"49846","inReplyTo":null,"subject":"Cygwin Git with Windows paths","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-18T15:21:58Z","receivedAt":"2018-11-18T15:24:10Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Cygwin programs can handle Unix form paths:\n\n    $ ls /var\n    cache  lib  log  run  tmp\n\nand also Windows form paths:\n\n    $ ls 'C:\\cygwin64\\var'\n    cache  lib  log  run  tmp\n\nHowever current Cygwin Git cannot:\n\n    $ git clone git://github.com/benhoyt/goawk 'C:\\cygwin64\\tmp\\goawk'\n    Cloning into 'C:\\cygwin64\\tmp\\goawk'...\n    fatal: Invalid path '/home/Steven/C:\\cygwin64\\tmp\\goawk': No such file or\n    directory\n\nIt seems the problem is that Git thinks the Windows form path is relative\nbecause it does not start with \"/\". A Git Bisect reveals this:\n\n05b458c104708141d2fad211d79703b3b99cc5a8 is the first bad commit\ncommit 05b458c104708141d2fad211d79703b3b99cc5a8\nAuthor: Brandon Williams <bmwill@google.com>\nDate:   Mon Dec 12 10:16:52 2016 -0800\n\n    real_path: resolve symlinks by hand\n\n    The current implementation of real_path uses chdir() in order to resolve\n    symlinks.  Unfortunately this isn't thread-safe as chdir() affects a\n    process as a whole and not just an individual thread.  Instead perform\n    the symlink resolution by hand so that the calls to chdir() can be\n    removed, making real_path one step closer to being reentrant.\n\n    Signed-off-by: Brandon Williams <bmwill@google.com>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nThis causes problems for any non-Cygwin tools that might call Git:\n\nhttp://github.com/golang/go/issues/23155\n\n"},{"id":"363580","messageId":"20181118154124.GA21680@tor.lan","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"Re: Cygwin Git with Windows paths","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-18T15:41:24Z","receivedAt":"2018-11-18T15:41:29Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sun, Nov 18, 2018 at 07:21:58AM -0800, Steven Penny wrote:\n> Cygwin programs can handle Unix form paths:\n> \n>    $ ls /var\n>    cache  lib  log  run  tmp\n> \n> and also Windows form paths:\n> \n>    $ ls 'C:\\cygwin64\\var'\n>    cache  lib  log  run  tmp\n> \n> However current Cygwin Git cannot:\n> \n>    $ git clone git://github.com/benhoyt/goawk 'C:\\cygwin64\\tmp\\goawk'\n>    Cloning into 'C:\\cygwin64\\tmp\\goawk'...\n>    fatal: Invalid path '/home/Steven/C:\\cygwin64\\tmp\\goawk': No such file or\n>    directory\n> \n> It seems the problem is that Git thinks the Windows form path is relative\n> because it does not start with \"/\". A Git Bisect reveals this:\n> \n> 05b458c104708141d2fad211d79703b3b99cc5a8 is the first bad commit\n> commit 05b458c104708141d2fad211d79703b3b99cc5a8\n> Author: Brandon Williams <bmwill@google.com>\n> Date:   Mon Dec 12 10:16:52 2016 -0800\n> \n>    real_path: resolve symlinks by hand\n> \n>    The current implementation of real_path uses chdir() in order to resolve\n>    symlinks.  Unfortunately this isn't thread-safe as chdir() affects a\n>    process as a whole and not just an individual thread.  Instead perform\n>    the symlink resolution by hand so that the calls to chdir() can be\n>    removed, making real_path one step closer to being reentrant.\n> \n>    Signed-off-by: Brandon Williams <bmwill@google.com>\n>    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> \n> This causes problems for any non-Cygwin tools that might call Git:\n> \n> http://github.com/golang/go/issues/23155\n> \n\nThanks for the report\nIt seams as if \"C:\" is not recognized as an absolute path under\ncygwin.\nMay be it should ?\n\nDoes the following help ? (fully untested)\n\n\ndiff --git a/compat/cygwin.h b/compat/cygwin.h\nindex 8e52de4644..12814e1edb 100644\n--- a/compat/cygwin.h\n+++ b/compat/cygwin.h\n@@ -1,2 +1,4 @@\n int cygwin_offset_1st_component(const char *path);\n #define offset_1st_component cygwin_offset_1st_component\n+#define has_dos_drive_prefix(path) \\\n+       (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n"},{"id":"363581","messageId":"CAAXzdLXSJU5bC_D1Q_gCWqKG7mcdcAvRkiYzano-VsrRRxazDQ@mail.gmail.com","threadId":"49846","inReplyTo":"20181118154124.GA21680@tor.lan","subject":"Re: Cygwin Git with Windows paths","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-18T16:23:19Z","receivedAt":"2018-11-18T16:23:32Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Sun, Nov 18, 2018 at 9:41 AM Torsten Bögershausen wrote:\n> Thanks for the report\n> It seams as if \"C:\" is not recognized as an absolute path under\n> cygwin.\n> May be it should ?\n>\n> Does the following help ? (fully untested)\n\nthat looks promising - but its not getting pulled in where it needs to be.\nperhaps another file need to be modified to utilize that macro?\n"},{"id":"363589","messageId":"20181118171525.GA25854@tor.lan","threadId":"49846","inReplyTo":"CAAXzdLXSJU5bC_D1Q_gCWqKG7mcdcAvRkiYzano-VsrRRxazDQ@mail.gmail.com","subject":"Re: Cygwin Git with Windows paths","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-18T17:15:25Z","receivedAt":"2018-11-18T17:15:28Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sun, Nov 18, 2018 at 10:23:19AM -0600, Steven Penny wrote:\n> On Sun, Nov 18, 2018 at 9:41 AM Torsten Bögershausen wrote:\n> > Thanks for the report\n> > It seams as if \"C:\" is not recognized as an absolute path under\n> > cygwin.\n> > May be it should ?\n> >\n> > Does the following help ? (fully untested)\n> \n> that looks promising - but its not getting pulled in where it needs to be.\n> perhaps another file need to be modified to utilize that macro?\n\nThe macro should be utilized, see git-compat-util.h:\n\n#if defined(__CYGWIN__)\n#include \"compat/cygwin.h\"\n#endif\n\nAnd further down\n\n#ifndef has_dos_drive_prefix\nstatic inline int git_has_dos_drive_prefix(const char *path)\n{\n\treturn 0;\n}\n#define has_dos_drive_prefix git_has_dos_drive_prefix\n#endif\n\n#ifndef skip_dos_drive_prefix\nstatic inline int git_skip_dos_drive_prefix(char **path)\n{\n\treturn 0;\n}\n--------------------\nBut it may be that we need to pull in more stuff, similar to mingw,\nto get the C: stuff working, see\n\"skip_dos_drive_prefix\"\n\nAnd it may even be that we need a special handling for the \"\\\" to be treated\nas \"/\".\n\nIf you implement \"skip_dos_drive_prefix\" similar to mingw,\n(rename mingw into cygwin) does\n\ngit clone <source> C:/my/dir/\nwork ?\n\nThat would be a progress, I think.\n"},{"id":"363590","messageId":"CAAXzdLXmJ1YKiTF17b=ZfkM3HtJCNkvVMQNU=riW8R42VLid_Q@mail.gmail.com","threadId":"49846","inReplyTo":"20181118171525.GA25854@tor.lan","subject":"Re: Cygwin Git with Windows paths","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-18T17:34:04Z","receivedAt":"2018-11-18T17:34:17Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Sun, Nov 18, 2018 at 11:15 AM Torsten Bögershausen wrote:\n> But it may be that we need to pull in more stuff, similar to mingw,\n> to get the C: stuff working, see\n> \"skip_dos_drive_prefix\"\n>\n> And it may even be that we need a special handling for the \"\\\" to be treated\n> as \"/\".\n>\n> If you implement \"skip_dos_drive_prefix\" similar to mingw,\n> (rename mingw into cygwin) does\n>\n> git clone <source> C:/my/dir/\n> work ?\n\nI added this to \"compat/cygwin.h\":\n\n    #define has_dos_drive_prefix(path) \\\n      (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n    int mingw_skip_dos_drive_prefix(char **path);\n    #define skip_dos_drive_prefix mingw_skip_dos_drive_prefix\n\nand added this to \"compat/cygwin.c\":\n\n    int mingw_skip_dos_drive_prefix(char **path) {\n      int ret = has_dos_drive_prefix(*path);\n      *path += ret;\n      return ret;\n    }\n\nbut still, these dont work:\n\n    git clone <source> C:/my/dir\n    git clone <source> 'C:\\my\\dir'\n"},{"id":"363591","messageId":"20181118182847.GA31405@tor.lan","threadId":"49846","inReplyTo":"CAAXzdLXmJ1YKiTF17b=ZfkM3HtJCNkvVMQNU=riW8R42VLid_Q@mail.gmail.com","subject":"Re: Cygwin Git with Windows paths","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-18T18:28:47Z","receivedAt":"2018-11-18T18:28:50Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sun, Nov 18, 2018 at 11:34:04AM -0600, Steven Penny wrote:\n> On Sun, Nov 18, 2018 at 11:15 AM Torsten Bögershausen wrote:\n> > But it may be that we need to pull in more stuff, similar to mingw,\n> > to get the C: stuff working, see\n> > \"skip_dos_drive_prefix\"\n> >\n> > And it may even be that we need a special handling for the \"\\\" to be treated\n> > as \"/\".\n> >\n> > If you implement \"skip_dos_drive_prefix\" similar to mingw,\n> > (rename mingw into cygwin) does\n> >\n> > git clone <source> C:/my/dir/\n> > work ?\n> \n> I added this to \"compat/cygwin.h\":\n> \n>     #define has_dos_drive_prefix(path) \\\n>       (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n>     int mingw_skip_dos_drive_prefix(char **path);\n>     #define skip_dos_drive_prefix mingw_skip_dos_drive_prefix\n> \n> and added this to \"compat/cygwin.c\":\n> \n>     int mingw_skip_dos_drive_prefix(char **path) {\n>       int ret = has_dos_drive_prefix(*path);\n>       *path += ret;\n>       return ret;\n>     }\n> \n> but still, these dont work:\n> \n>     git clone <source> C:/my/dir\n>     git clone <source> 'C:\\my\\dir'\n\nThanks for testing.\nIt looks as if there is more work to be done then just a simple patch.\n\nMy last question for today:\nDoes \n\ngit clone <source> '/cgdrive/c/my/dir'\n\nwork ?\n\n"},{"id":"363592","messageId":"CAAXzdLWByGC+B_XdDiJwounoPgMAsMq=EuOSx9bdV-f5vQUhnA@mail.gmail.com","threadId":"49846","inReplyTo":"20181118182847.GA31405@tor.lan","subject":"Re: Cygwin Git with Windows paths","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-18T19:00:10Z","receivedAt":"2018-11-18T19:00:24Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Sun, Nov 18, 2018 at 12:28 PM Torsten Bögershausen wrote:\n> Thanks for testing.\n> It looks as if there is more work to be done then just a simple patch.\n>\n> My last question for today:\n> Does\n>\n> git clone <source> '/cgdrive/c/my/dir'\n>\n> work ?\n\nyes - these all work and resolve to same path:\n\n   git clone <source> /tmp/goawk\n   git clone <source> /cygdrive/c/cygwin64/tmp/goawk\n   git clone <source> /proc/cygdrive/c/cygwin64/tmp/goawk\n\nhowever i would caution that any fix should not rely on \"C:\", as users are\nallowed to install to other volumes such as \"D:\". Perhaps a better solution\nwould be for Git to just take the path as is, rather than converting it to an\nabsolute path?\n"},{"id":"363604","messageId":"xmqqsgzydj6n.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"20181118171525.GA25854@tor.lan","subject":"Re: Cygwin Git with Windows paths","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-19T00:06:56Z","receivedAt":"2018-11-19T00:07:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> And it may even be that we need a special handling for the \"\\\" to be treated\n> as \"/\".\n\nI do not do Windows, but is_dir_sep() needs to be tweaked if you\nwant to do that.\n"},{"id":"363609","messageId":"005801d47fad$345d5a70$9d180f50$@nexbridge.com","threadId":"49846","inReplyTo":"xmqqsgzydj6n.fsf@gitster-ct.c.googlers.com","subject":"RE: Cygwin Git with Windows paths","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2018-11-19T02:11:32Z","receivedAt":"2018-11-19T02:11:42Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"> -----Original Message-----\n> From: git-owner@vger.kernel.org <git-owner@vger.kernel.org> On Behalf Of\n> Junio C Hamano\n> Sent: November 18, 2018 19:07\n> To: Torsten Bögershausen <tboegi@web.de>\n> Cc: Steven Penny <svnpenn@gmail.com>; git@vger.kernel.org\n> Subject: Re: Cygwin Git with Windows paths\n> \n> Torsten Bögershausen <tboegi@web.de> writes:\n> \n> > And it may even be that we need a special handling for the \"\\\" to be\n> > treated as \"/\".\n> \n> I do not do Windows, but is_dir_sep() needs to be tweaked if you want to do\n> that.\n\nHeavy Cygwin user here. It is used in my environment for cross-compilation. Everything should be done using / separators in Cygwin, not \\. So /cygdrive/c, /cygdrive/d always prefaces the path rather than C:\\ or D:\\, which won't parse. It is, essentially, a bash environment, including that git completions work properly. Backslash ends up doing what it would in bash.\n\n"},{"id":"363614","messageId":"xmqqbm6leo7g.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"005801d47fad$345d5a70$9d180f50$@nexbridge.com","subject":"Re: Cygwin Git with Windows paths","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-19T03:33:07Z","receivedAt":"2018-11-19T03:33:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Randall S. Becker\" <rsbecker@nexbridge.com> writes:\n\n>> Torsten Bögershausen <tboegi@web.de> writes:\n>> \n>> > And it may even be that we need a special handling for the \"\\\" to be\n>> > treated as \"/\".\n>> \n>> I do not do Windows, but is_dir_sep() needs to be tweaked if you want to do\n>> that.\n>\n> Heavy Cygwin user here. It is used in my environment for\n> cross-compilation. Everything should be done using / separators in\n> Cygwin, not \\. So /cygdrive/c, /cygdrive/d always prefaces the\n> path rather than C:\\ or D:\\, which won't parse. It is,\n> essentially, a bash environment, including that git completions\n> work properly. Backslash ends up doing what it would in bash.\n\nIn short, in your opinion, the original message in this thread\nexpresses an invalid wish, as C:\\path\\to\\dir\\ is not a valid way to\nspell the path to the directory, and it should be written as\n/cygdrive/c/path/to/dir instead?\n\nHow well does this argument work in the real world, when another\nclaim in the original message\n\n    This causes problems for any non-Cygwin tools that might call Git:\n\n    http://github.com/golang/go/issues/23155\n\nis taken into account, I wonder, though?\n"},{"id":"363618","messageId":"bddb9e06-2688-c459-9467-a3f0978866f9@web.de","threadId":"49846","inReplyTo":"xmqqbm6leo7g.fsf@gitster-ct.c.googlers.com","subject":"Re: Cygwin Git with Windows paths","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-19T05:20:51Z","receivedAt":"2018-11-19T05:21:15Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2018-11-19 04:33, Junio C Hamano wrote:\n> \"Randall S. Becker\" <rsbecker@nexbridge.com> writes:\n> \n>>> Torsten Bögershausen <tboegi@web.de> writes:\n>>>\n>>>> And it may even be that we need a special handling for the \"\\\" to be\n>>>> treated as \"/\".\n>>>\n>>> I do not do Windows, but is_dir_sep() needs to be tweaked if you want to do\n>>> that.\n>>\n>> Heavy Cygwin user here. It is used in my environment for\n>> cross-compilation. Everything should be done using / separators in\n>> Cygwin, not \\. So /cygdrive/c, /cygdrive/d always prefaces the\n>> path rather than C:\\ or D:\\, which won't parse. It is,\n>> essentially, a bash environment, including that git completions\n>> work properly. Backslash ends up doing what it would in bash.\n> \n> In short, in your opinion, the original message in this thread\n> expresses an invalid wish, as C:\\path\\to\\dir\\ is not a valid way to\n> spell the path to the directory, and it should be written as\n> /cygdrive/c/path/to/dir instead?\n> \n> How well does this argument work in the real world, when another\n> claim in the original message\n> \n>     This causes problems for any non-Cygwin tools that might call Git:\n> \n>     http://github.com/golang/go/issues/23155\n> \n> is taken into account, I wonder, though?\n> \n\n\nBack to the original email, where the path embedded in ''\nand the bash does not interpret the \"\\\", I think.\n\n>   $ git clone git://github.com/benhoyt/goawk 'C:\\cygwin64\\tmp\\goawk'\n>   Cloning into 'C:\\cygwin64\\tmp\\goawk'...\n>   fatal: Invalid path '/home/Steven/C:\\cygwin64\\tmp\\goawk': No such file or\n>   directory\n\n>It seems the problem is that Git thinks the Windows form path is relative\n>because it does not start with \"/\".\n\n>A Git Bisect reveals this:\n>05b458c104708141d2fad211d79703b3b99cc5a8 is the first bad commit\n>commit 05b458c104708141d2fad211d79703b3b99cc5a8\n>Author: Brandon Williams <bmwill@google.com>\n>Date:   Mon Dec 12 10:16:52 2016 -0800\n\n\nThe first question is, does this work under Git for Windows ?\n\nLooking into 05b458c104708141d2fad, it seems as if the following functions\nneed to be \"overridden\" for cygwin, similar as we do it for mingw:\n is_dir_sep()\n offset_1st_component()\n find_last_dir_sep()\n\n\nIf nothing works,\nit may help to add some fprintf(stderr,...) in the functions used\nby 05b458c104708141d2f:\n\nstrip_last_component(),\nget_next_component()\nreal_path_internal()\n"},{"id":"363630","messageId":"006d01d48002$9741aa60$c5c4ff20$@nexbridge.com","threadId":"49846","inReplyTo":"xmqqbm6leo7g.fsf@gitster-ct.c.googlers.com","subject":"RE: Cygwin Git with Windows paths","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2018-11-19T12:22:45Z","receivedAt":"2018-11-19T12:22:56Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On November 18, 2018 22:33, Junio C Hamano wrote:\n> \"Randall S. Becker\" <rsbecker@nexbridge.com> writes:\n> \n> >> Torsten Bögershausen <tboegi@web.de> writes:\n> >>\n> >> > And it may even be that we need a special handling for the \"\\\" to\n> >> > be treated as \"/\".\n> >>\n> >> I do not do Windows, but is_dir_sep() needs to be tweaked if you want\n> >> to do that.\n> >\n> > Heavy Cygwin user here. It is used in my environment for\n> > cross-compilation. Everything should be done using / separators in\n> > Cygwin, not \\. So /cygdrive/c, /cygdrive/d always prefaces the path\n> > rather than C:\\ or D:\\, which won't parse. It is, essentially, a bash\n> > environment, including that git completions work properly. Backslash\n> > ends up doing what it would in bash.\n> \n> In short, in your opinion, the original message in this thread expresses an\n> invalid wish, as C:\\path\\to\\dir\\ is not a valid way to spell the path to the\n> directory, and it should be written as /cygdrive/c/path/to/dir instead?\n> \n> How well does this argument work in the real world, when another claim in\n> the original message\n> \n>     This causes problems for any non-Cygwin tools that might call Git:\n> \n>     http://github.com/golang/go/issues/23155\n> \n> is taken into account, I wonder, though?\n\nThe solution to this that I ended up with is a blend of many different implementations of git (3) on my dev box. EGit in ECLIPSE, standard windows git for working in a CMD prompt, the Cygwin git in Cygwin bash. On another dev box I also have git bash and Ming, which make things easier, but I have to work in Cygwin for some subsystems. I end up using relative paths with / instead of \\ in all cases, and git seems happy, except for /cygdrive/c. Absolute Windows and Cygwin paths simply do not work consistently, from my experience from Cygwin because of the way bash passes arguments to non-cygwin tools. You need to be very careful and properly escape \"\\\" to do so, and account for cygwin drive handling otherwise. So a non-cygwin tool from Cygwin can process c:\\ but Cygwin itself will not. My own expectations are that git built for Cygwin would understand this, but git built for Windows would not, and that I should account for this through my PATH, selecting Cygwin git in Cygwin and Windows git elsewhere. Reality may not reflect this, so I use relative paths in all cases (non-reality being that the git port for Cygwin is different than the git port for Windows, which it does not appear to be).\n\nCheers,\nRandall\n\n\n"},{"id":"363685","messageId":"CAAXzdLXCEeZdkCXT+-0n=Fn7_=Nz5cm+6xr0w-cd6B1om028uA@mail.gmail.com","threadId":"49846","inReplyTo":"bddb9e06-2688-c459-9467-a3f0978866f9@web.de","subject":"Re: Cygwin Git with Windows paths","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-20T00:17:50Z","receivedAt":"2018-11-20T00:18:02Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Sun, Nov 18, 2018 at 11:21 PM Torsten Bögershausen wrote:\n> If nothing works,\n> it may help to add some fprintf(stderr,...) in the functions used\n> by 05b458c104708141d2f:\n>\n> strip_last_component(),\n> get_next_component()\n> real_path_internal()\n\nI didnt see any \"real_path_internal\" in the current codebase - however i added\nsome \"printf\" to the other 2 and got this:\n\n$ git clone git://github.com/benhoyt/goawk 'C:\\cygwin64\\tmp\\goawk'\nget_next_component, next, []\nget_next_component, remaining, [C:\\cygwin64\\tmp\\goawk]\nCloning into 'C:\\cygwin64\\tmp\\goawk'...\nget_next_component, next, []\nget_next_component, remaining, [C:\\cygwin64\\tmp\\goawk/.git]\nfatal: Invalid path '/usr/local/cache/git/C:\\cygwin64\\tmp\\goawk': No such file\nor directory\n"},{"id":"363721","messageId":"9bee0f47-d1fb-c483-2597-d8edb1ed36de@web.de","threadId":"49846","inReplyTo":"CAAXzdLXCEeZdkCXT+-0n=Fn7_=Nz5cm+6xr0w-cd6B1om028uA@mail.gmail.com","subject":"Re: Cygwin Git with Windows paths","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-11-20T10:36:20Z","receivedAt":"2018-11-20T10:36:33Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 20.11.18 01:17, Steven Penny wrote:\n> On Sun, Nov 18, 2018 at 11:21 PM Torsten Bögershausen wrote:\n>> If nothing works,\n>> it may help to add some fprintf(stderr,...) in the functions used\n>> by 05b458c104708141d2f:\n>>\n>> strip_last_component(),\n>> get_next_component()\n>> real_path_internal()\n> \n> I didnt see any \"real_path_internal\" in the current codebase - however i added\n> some \"printf\" to the other 2 and got this:\n> \n> $ git clone git://github.com/benhoyt/goawk 'C:\\cygwin64\\tmp\\goawk'\n> get_next_component, next, []\n> get_next_component, remaining, [C:\\cygwin64\\tmp\\goawk]\n> Cloning into 'C:\\cygwin64\\tmp\\goawk'...\n> get_next_component, next, []\n> get_next_component, remaining, [C:\\cygwin64\\tmp\\goawk/.git]\n> fatal: Invalid path '/usr/local/cache/git/C:\\cygwin64\\tmp\\goawk': No such file\n> or directory\n> \n\nCould you please post a \"git diff\" of your instrumented code,\nso that I/we can follow the debugging, especially what the printouts mean?\n\nI think we need to understand what is going on in abspath.c\n\n"},{"id":"363735","messageId":"CAAXzdLU3dsCabgYKnD9c7iWZcXx1cfO3tisJ7r0dNjiiTHk1mA@mail.gmail.com","threadId":"49846","inReplyTo":"9bee0f47-d1fb-c483-2597-d8edb1ed36de@web.de","subject":"Re: Cygwin Git with Windows paths","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-20T12:51:57Z","receivedAt":"2018-11-20T12:52:07Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Tue, Nov 20, 2018 at 4:36 AM Torsten Bögershausen wrote:\n> Could you please post a \"git diff\" of your instrumented code,\n> so that I/we can follow the debugging, especially what the printouts mean?\n>\n> I think we need to understand what is going on in abspath.c\n>\n\ndiff --git a/abspath.c b/abspath.c\nindex 9857985..09548e5 100644\n--- a/abspath.c\n+++ b/abspath.c\n@@ -14,6 +14,7 @@ int is_directory(const char *path)\n /* removes the last path component from 'path' except if 'path' is root */\n static void strip_last_component(struct strbuf *path)\n {\n+       printf(\"strip_last_component, path, [%s]\\n\", path->buf);\n        size_t offset = offset_1st_component(path->buf);\n        size_t len = path->len;\n\n@@ -30,6 +31,8 @@ static void strip_last_component(struct strbuf *path)\n /* get (and remove) the next component in 'remaining' and place it in 'next' */\n static void get_next_component(struct strbuf *next, struct strbuf *remaining)\n {\n+       printf(\"get_next_component, next, [%s]\\n\", next->buf);\n+       printf(\"get_next_component, remaining, [%s]\\n\", remaining->buf);\n        char *start = NULL;\n        char *end = NULL;\n"},{"id":"364087","messageId":"20181126173252.1558-1-tboegi@web.de","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"[PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-11-26T17:32:52Z","receivedAt":"2018-11-26T17:32:58Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nA regression for cygwin users was introduced with commit 05b458c,\n \"real_path: resolve symlinks by hand\".\n\nIn the the commit message we read:\n  The current implementation of real_path uses chdir() in order to resolve\n  symlinks.  Unfortunately this isn't thread-safe as chdir() affects a\n  process as a whole...\n\nThe old (and non-thread-save) OS calls chdir()/pwd() had been\nreplaced by a string operation.\nThe cygwin layer \"knows\" that \"C:\\cygwin\" is an absolute path,\nbut the new string operation does not.\n\n\"git clone <url> C:\\cygwin\\home\\USER\\repo\" fails like this:\nfatal: Invalid path '/home/USER/repo/C:\\cygwin\\home\\USER\\repo'\n\nThe solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\nis_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\nin the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n\nReported-By: Steven Penny <svnpenn@gmail.com>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n\nThis is the first vesion of a patch.\nIs there a chance that you test it ?\n\nabspath.c       |  2 +-\n compat/cygwin.c | 18 ++++++++++++++----\n compat/cygwin.h | 32 ++++++++++++++++++++++++++++++++\n 3 files changed, 47 insertions(+), 5 deletions(-)\n\ndiff --git a/abspath.c b/abspath.c\nindex 9857985329..77a281f789 100644\n--- a/abspath.c\n+++ b/abspath.c\n@@ -55,7 +55,7 @@ static void get_root_part(struct strbuf *resolved, struct strbuf *remaining)\n \n \tstrbuf_reset(resolved);\n \tstrbuf_add(resolved, remaining->buf, offset);\n-#ifdef GIT_WINDOWS_NATIVE\n+#if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)\n \tconvert_slashes(resolved->buf);\n #endif\n \tstrbuf_remove(remaining, 0, offset);\ndiff --git a/compat/cygwin.c b/compat/cygwin.c\nindex b9862d606d..c4a10cb5a1 100644\n--- a/compat/cygwin.c\n+++ b/compat/cygwin.c\n@@ -1,19 +1,29 @@\n #include \"../git-compat-util.h\"\n #include \"../cache.h\"\n \n+int cygwin_skip_dos_drive_prefix(char **path)\n+{\n+\tint ret = has_dos_drive_prefix(*path);\n+\t*path += ret;\n+\treturn ret;\n+}\n+\n int cygwin_offset_1st_component(const char *path)\n {\n-\tconst char *pos = path;\n+\tchar *pos = (char *)path;\n+\n \t/* unc paths */\n-\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n+\tif (!skip_dos_drive_prefix(&pos) &&\n+\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n \t\t/* skip server name */\n-\t\tpos = strchr(pos + 2, '/');\n+\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n \t\tif (!pos)\n \t\t\treturn 0; /* Error: malformed unc path */\n \n \t\tdo {\n \t\t\tpos++;\n-\t\t} while (*pos && pos[0] != '/');\n+\t\t} while (*pos && !is_dir_sep(*pos));\n \t}\n+\n \treturn pos + is_dir_sep(*pos) - path;\n }\ndiff --git a/compat/cygwin.h b/compat/cygwin.h\nindex 8e52de4644..46f29c0a90 100644\n--- a/compat/cygwin.h\n+++ b/compat/cygwin.h\n@@ -1,2 +1,34 @@\n+#define has_dos_drive_prefix(path) \\\n+\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n+\n+\n+int cygwin_offset_1st_component(const char *path);\n+#define offset_1st_component cygwin_offset_1st_component\n+\n+\n+#define has_dos_drive_prefix(path) \\\n+\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n+int cygwin_skip_dos_drive_prefix(char **path);\n+#define skip_dos_drive_prefix cygwin_skip_dos_drive_prefix\n+static inline int cygwin_is_dir_sep(int c)\n+{\n+\treturn c == '/' || c == '\\\\';\n+}\n+#define is_dir_sep cygwin_is_dir_sep\n+static inline char *cygwin_find_last_dir_sep(const char *path)\n+{\n+\tchar *ret = NULL;\n+\tfor (; *path; ++path)\n+\t\tif (is_dir_sep(*path))\n+\t\t\tret = (char *)path;\n+\treturn ret;\n+}\n+static inline void convert_slashes(char *path)\n+{\n+\tfor (; *path; path++)\n+\t\tif (*path == '\\\\')\n+\t\t\t*path = '/';\n+}\n+#define find_last_dir_sep cygwin_find_last_dir_sep\n int cygwin_offset_1st_component(const char *path);\n #define offset_1st_component cygwin_offset_1st_component\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"364110","messageId":"CAAXzdLWBSD5coxqbyRN_d9B1e4AA-Q6VQ7iRo8BPuhBKDicMRQ@mail.gmail.com","threadId":"49846","inReplyTo":"20181126173252.1558-1-tboegi@web.de","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-27T00:35:26Z","receivedAt":"2018-11-27T00:35:36Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Mon, Nov 26, 2018 at 11:32 AM wrote:\n> This is the first vesion of a patch.\n> Is there a chance that you test it ?\n\nI can confirm that this fixes the issue.\n\nThank you!\n"},{"id":"364114","messageId":"xmqqtvk3tj45.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"20181126173252.1558-1-tboegi@web.de","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-27T01:16:42Z","receivedAt":"2018-11-27T01:16:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> Reported-By: Steven Penny <svnpenn@gmail.com>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>\n> This is the first vesion of a patch.\n> Is there a chance that you test it ?\n>\n> abspath.c       |  2 +-\n>  compat/cygwin.c | 18 ++++++++++++++----\n>  compat/cygwin.h | 32 ++++++++++++++++++++++++++++++++\n>  3 files changed, 47 insertions(+), 5 deletions(-)\n\nI am hoping that the funny indentation above is merely an accidental\ntouch on the delete key and not a sign of MUA eating the patch to\nmake it unapplicable (and making it harder for those who want to\ntest to test it).\n\n> diff --git a/compat/cygwin.c b/compat/cygwin.c\n> index b9862d606d..c4a10cb5a1 100644\n> --- a/compat/cygwin.c\n> +++ b/compat/cygwin.c\n> @@ -1,19 +1,29 @@\n>  #include \"../git-compat-util.h\"\n>  #include \"../cache.h\"\n>  \n> +int cygwin_skip_dos_drive_prefix(char **path)\n> +{\n> +\tint ret = has_dos_drive_prefix(*path);\n> +\t*path += ret;\n> +\treturn ret;\n> +}\n\nMental note: this is exactly the same as mingw version.\n\nI wonder if it makes the rest of the code simpler if we stripped\nthings like /cygdrive/c here exactly the sam way as we strip C:\nFor that, has_dos_drive_prefix() needs to know /cygdrive/[a-z],\nwhich may not be a bad thing, I guess.  Let's read on.\n\n>  int cygwin_offset_1st_component(const char *path)\n>  {\n> -\tconst char *pos = path;\n> +\tchar *pos = (char *)path;\n> +\n>  \t/* unc paths */\n> -\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n> +\tif (!skip_dos_drive_prefix(&pos) &&\n> +\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n\nWhen given C:\\foo\\bar, this strips prefix to leave \\foo\\bar in pos and\nthen realizes that it cannot be unc path (because it has dos prefix)\nand goes on.  What is returned from the function is \"\\foo\\bar\" + 1 -\npath, i.e. the offset in the original \"C:\\foo\\bar\" string of the\n'f' in \"foo\", i.e. 3.\n\nWhen given \\foo\\bar, pos stays the same as path, and it skips the\nfirst backslash and returns the offset in the original string of the\n'f' in \"foo\", i.e. 1.\n\nBoth cases return the moreal equivalent --- the offset of the first\ncomponent 'foo'.  So this looks correct for these two cases.\n\n>  \t\t/* skip server name */\n> -\t\tpos = strchr(pos + 2, '/');\n> +\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n\nThis is to allow \\\\server\\path in addition to //server/path; the\noriginal looked only for '/' with strchr but we now look for either\n'/' or '\\', whichever comes earlier.  Both helpers return NULL when\nthey find no separator, so we should be able to handle the returned\npos from here on the same way as the original code.\n\n>  \t\tif (!pos)\n>  \t\t\treturn 0; /* Error: malformed unc path */\n>  \n>  \t\tdo {\n>  \t\t\tpos++;\n> -\t\t} while (*pos && pos[0] != '/');\n> +\t\t} while (*pos && !is_dir_sep(*pos));\n\nAnd whenever we looked for '/', we consider '\\' its equivalent.\n\n>  \t}\n> +\n>  \treturn pos + is_dir_sep(*pos) - path;\n>  }\n\nLooks good so far.\n\nWait, did I just waste time by not looking at mingw.c version?  I\nsuspect this would be exactly the same ;-)\n\n> diff --git a/compat/cygwin.h b/compat/cygwin.h\n> index 8e52de4644..46f29c0a90 100644\n> --- a/compat/cygwin.h\n> +++ b/compat/cygwin.h\n> @@ -1,2 +1,34 @@\n> +#define has_dos_drive_prefix(path) \\\n> +\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n\nMetanl note: this also looks the same as mingw version.\n\n> +int cygwin_offset_1st_component(const char *path);\n> +#define offset_1st_component cygwin_offset_1st_component\n> +\n\nSo, my real questions are\n\n - Is there a point in having cygwin specific variant of these, or\n   can we just borrow from mingw version (with some refactoring)?\n   Is there a point in doing so (e.g. if mingw plans to move to\n   reject forward slashes, attempting to share is pointless).\n\n - Would it make it better (or worse) to treat the /cygdrive/c thing\n   as another way to spell dos-drive-prefix?  If the answer is \"it\n   is a good idea\", then that answers the previous question\n   automatically (we cannot gain much by sharing, as mingw side\n   won't want to treat /cygdrive/c any differently).\n\n"},{"id":"364115","messageId":"CAAXzdLX4jU7+i1W1A_Q1LpPFa1D4FYVPW5rcMnqr_tDHEJn+tw@mail.gmail.com","threadId":"49846","inReplyTo":"xmqqtvk3tj45.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-27T02:49:38Z","receivedAt":"2018-11-27T02:49:50Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Mon, Nov 26, 2018 at 7:16 PM Junio C Hamano wrote:\n> I wonder if it makes the rest of the code simpler if we stripped\n> things like /cygdrive/c here exactly the sam way as we strip C:\n> For that, has_dos_drive_prefix() needs to know /cygdrive/[a-z],\n> which may not be a bad thing, I guess.  Let's read on.\n\nWith full paths, Cygwin can traverse drives:\n\n    $ cd 'C:\\Users'\n    $ pwd\n    /cygdrive/c/Users\n\n    $ cd 'D:\\Testing'\n    $ pwd\n    /cygdrive/d/Testing\n\nIf you strip the drive, you can still navigate within the same drive:\n\n    $ cd 'C:\\Users'\n    $ pwd\n    /cygdrive/c/Users\n\n    $ cd '\\Windows'\n    $ pwd\n    /cygdrive/c/Windows\n\nbut you can no longer traverse drives:\n\n    $ cd '\\Testing'\n    sh: cd: \\Testing: No such file or directory\n\nSo a good first question for me would be: why are we stripping \"C:\" or similar\nin the first place?\n\n>  - Is there a point in having cygwin specific variant of these, or\n>    can we just borrow from mingw version (with some refactoring)?\n>    Is there a point in doing so (e.g. if mingw plans to move to\n>    reject forward slashes, attempting to share is pointless).\n\nI would say these could be merged into a \"win.h\" or similar. Cygwin typically\nleans toward the \"/unix/style\" while MINGW has been more tolerant of\n\"C:\\Windows\\Style\" and \"C:/Mixed/Style\" paths, i dont see that changing.\n"},{"id":"364118","messageId":"xmqqlg5ft7pe.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"CAAXzdLX4jU7+i1W1A_Q1LpPFa1D4FYVPW5rcMnqr_tDHEJn+tw@mail.gmail.com","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-27T05:23:09Z","receivedAt":"2018-11-27T05:23:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> If you strip the drive, you can still navigate within the same drive:\n>\n>     $ cd 'C:\\Users'\n>     $ pwd\n>     /cygdrive/c/Users\n>\n>     $ cd '\\Windows'\n>     $ pwd\n>     /cygdrive/c/Windows\n>\n> but you can no longer traverse drives:\n>\n>     $ cd '\\Testing'\n>     sh: cd: \\Testing: No such file or directory\n\nSorry, but I fail to see the point the last example wants to make.\nIf it were\n\n    $ cd /cygdrive/d/Testing\n    $ cd /cygdrive/c/Users\n    $ cd ../../d/Testing\n\nand the last step fails, then I would suspect it would make sense to\ntreat /cygdrive/$X exactly like how we would treat $C:, because\n\n    $ cd C:Users\n    $ cd ../D:Testing\n\nwould not make sense, either, which is an indication that these two\nare quite similar.  On the other hand, if \"cd ../../d/Testing\" above\ndoes not fail and does what non-DOS users would expect, then that\nstrongly argues that treating /cygdrive/$X any specially is a mistake.\n\n> So a good first question for me would be: why are we stripping \"C:\" or similar\n> in the first place?\n\nSorry, but I do not see the connection to this question and the\nabove example.  The reason why we strip C: is because the letter\nthat comes after that colon determines if we are talking about\nabsolute path (in other words, the current directory does not play a\nrole in determining which directory the path refers to), unlike the\nPOSIX codepath where it is always the first letter in the pathname.\n\nC:\\Users is a directory whose name is Users at the top level of the\nC: drive. C0\\Users tells us that in the current directory, there is\na directory whose name is C0 and in it, there is a filesystem entity\nwhose name is Users.  So the colon that follows an alpha (in this\ncase, C:) is quite special, compared to other letters (in this\nexample, I used '0' to contrast its effect with ':').  So it is very\nunderstandable why we want to have has_dos_prefix() and\nskip_dos_prefix().\n\n> I would say these could be merged into a \"win.h\" or similar. Cygwin typically\n> leans toward the \"/unix/style\" while MINGW has been more tolerant of\n> \"C:\\Windows\\Style\" and \"C:/Mixed/Style\" paths, i dont see that changing.\n\nI'd defer to Windows folks to decide if a unified win.h is a good\nidea.\n\nThanks.\n"},{"id":"364120","messageId":"CAAXzdLWtDw09umyr23qZkv2jQ6_mTeFXbktgb-f6S2w6Zf1Egg@mail.gmail.com","threadId":"49846","inReplyTo":"xmqqlg5ft7pe.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-11-27T06:20:14Z","receivedAt":"2018-11-27T06:20:24Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Mon, Nov 26, 2018 at 11:23 PM Junio C Hamano wrote:\n> Sorry, but I do not see the connection to this question and the\n> above example.  The reason why we strip C: is because the letter\n> that comes after that colon determines if we are talking about\n> absolute path (in other words, the current directory does not play a\n> role in determining which directory the path refers to), unlike the\n> POSIX codepath where it is always the first letter in the pathname.\n\nwhile it is true that \"C:\" and similar do not have a bearing on a path being\nabsolute versus relative, it does have a bearing on what drive the entry is to\nbe found.\n\nThat is to say \"C:\\tmp\\file.txt\" does not equal \"D:\\tmp\\file.txt\".\n\nStarting with an absolute path like \"C:\\tmp\\file.txt\", after stripping that\nwould yield \"\\tmp\\file.txt\" or \"/tmp/file.txt\". Starting with a relative path\nlike \"C:tmp\\file.txt\", after stripping that would yield \"tmp\\file.txt\" or\n\"tmp/file.txt\".\n\nHowever in all cases we have lost the concept of what drive the file is located\non, and Windows will assume the file exists on the current drive.\n\nSo I would expect \"git clone URL D:\\tmp\" to fail if the current directory is on\n\"C:\". Upon testing cross drive clones work fine though with this patch, so maybe\nthe drive is added back at another place in the code.\n"},{"id":"364127","messageId":"nycvar.QRO.7.76.6.1811271346550.41@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"20181126173252.1558-1-tboegi@web.de","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-11-27T12:49:35Z","receivedAt":"2018-11-27T12:49:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Torsten,\n\nOn Mon, 26 Nov 2018, tboegi@web.de wrote:\n\n> diff --git a/compat/cygwin.c b/compat/cygwin.c\n> index b9862d606d..c4a10cb5a1 100644\n> --- a/compat/cygwin.c\n> +++ b/compat/cygwin.c\n> @@ -1,19 +1,29 @@\n>  #include \"../git-compat-util.h\"\n>  #include \"../cache.h\"\n>  \n> +int cygwin_skip_dos_drive_prefix(char **path)\n> +{\n> +\tint ret = has_dos_drive_prefix(*path);\n> +\t*path += ret;\n> +\treturn ret;\n> +}\n> +\n>  int cygwin_offset_1st_component(const char *path)\n>  {\n> -\tconst char *pos = path;\n> +\tchar *pos = (char *)path;\n> +\n>  \t/* unc paths */\n> -\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n> +\tif (!skip_dos_drive_prefix(&pos) &&\n> +\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n\nIt takes a little folding and knotting of the brain to understand that\nthis `!skip_dos_drive_prefix(&pos)` has *nothing* to do with the comment\n`unc paths` nor with the test whether the paths starts with two directory\nseparators.\n\nAs a consequence, I would highly suggest to turn this into:\n\n\tif (skip_dos_drive_prefix(&pos))\n\t\t; /* absolute path with DOS drive prefix */\n  \t/* unc paths */\n\telse if (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n\nThat makes the code a lot easier to understand, and as a consequence a lot\nharder to mess up in the future.\n\nThanks,\nDscho\n\n>  \t\t/* skip server name */\n> -\t\tpos = strchr(pos + 2, '/');\n> +\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n>  \t\tif (!pos)\n>  \t\t\treturn 0; /* Error: malformed unc path */\n>  \n>  \t\tdo {\n>  \t\t\tpos++;\n> -\t\t} while (*pos && pos[0] != '/');\n> +\t\t} while (*pos && !is_dir_sep(*pos));\n>  \t}\n> +\n>  \treturn pos + is_dir_sep(*pos) - path;\n>  }\n> diff --git a/compat/cygwin.h b/compat/cygwin.h\n> index 8e52de4644..46f29c0a90 100644\n> --- a/compat/cygwin.h\n> +++ b/compat/cygwin.h\n> @@ -1,2 +1,34 @@\n> +#define has_dos_drive_prefix(path) \\\n> +\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n> +\n> +\n> +int cygwin_offset_1st_component(const char *path);\n> +#define offset_1st_component cygwin_offset_1st_component\n> +\n> +\n> +#define has_dos_drive_prefix(path) \\\n> +\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n> +int cygwin_skip_dos_drive_prefix(char **path);\n> +#define skip_dos_drive_prefix cygwin_skip_dos_drive_prefix\n> +static inline int cygwin_is_dir_sep(int c)\n> +{\n> +\treturn c == '/' || c == '\\\\';\n> +}\n> +#define is_dir_sep cygwin_is_dir_sep\n> +static inline char *cygwin_find_last_dir_sep(const char *path)\n> +{\n> +\tchar *ret = NULL;\n> +\tfor (; *path; ++path)\n> +\t\tif (is_dir_sep(*path))\n> +\t\t\tret = (char *)path;\n> +\treturn ret;\n> +}\n> +static inline void convert_slashes(char *path)\n> +{\n> +\tfor (; *path; path++)\n> +\t\tif (*path == '\\\\')\n> +\t\t\t*path = '/';\n> +}\n> +#define find_last_dir_sep cygwin_find_last_dir_sep\n>  int cygwin_offset_1st_component(const char *path);\n>  #define offset_1st_component cygwin_offset_1st_component\n> -- \n> 2.19.0.271.gfe8321ec05\n> \n> \n"},{"id":"364128","messageId":"nycvar.QRO.7.76.6.1811271352560.41@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"xmqqlg5ft7pe.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-11-27T12:55:28Z","receivedAt":"2018-11-27T12:55:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Tue, 27 Nov 2018, Junio C Hamano wrote:\n\n> Steven Penny <svnpenn@gmail.com> writes:\n> \n> > If you strip the drive, you can still navigate within the same drive:\n> >\n> >     $ cd 'C:\\Users'\n> >     $ pwd\n> >     /cygdrive/c/Users\n> >\n> >     $ cd '\\Windows'\n> >     $ pwd\n> >     /cygdrive/c/Windows\n> >\n> > but you can no longer traverse drives:\n> >\n> >     $ cd '\\Testing'\n> >     sh: cd: \\Testing: No such file or directory\n> \n> Sorry, but I fail to see the point the last example wants to make.\n\nI agree. For me, the real test is this:\n\nme@work ~\n$ cd /cygdrive\n\nme@work /cygdrive\n$ ls\nc  d\n\nSo `/cygdrive` *is* a valid directory in Cygwin.\n\n> > I would say these could be merged into a \"win.h\" or similar. Cygwin typically\n> > leans toward the \"/unix/style\" while MINGW has been more tolerant of\n> > \"C:\\Windows\\Style\" and \"C:/Mixed/Style\" paths, i dont see that changing.\n> \n> I'd defer to Windows folks to decide if a unified win.h is a good\n> idea.\n\nWe already have such a thing, but it is not just `win.h`, it is\n`compat/win32/`. I would think that the best idea would be to move the\nMINGW variants to `compat/win32/path-utils.c` and declare them in\n`compat/win32/path-utils.h`, renaming them from `mingw_*()` to\n`win32_*()`.\n\nCiao,\nDscho\n"},{"id":"364158","messageId":"87d0qqqo9s.fsf@Rainer.invalid","threadId":"49846","inReplyTo":"20181126173252.1558-1-tboegi@web.de","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Achim Gratz","fromEmail":"stromeko@nexgo.de","sentAt":"2018-11-27T20:05:51Z","receivedAt":"2018-11-27T20:06:01Z","isPatch":true,"sender":{"key":"stromeko@nexgo.de","avatar":null},"body":"tboegi@web.de writes:\n> The solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\n> is_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\n> in the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n\nPlease use the Cygwin API path conversion functions for C code and the\ncygpath program for shell code instead of trying to re-implement your\nown handling (which is prone to introduce subtle bugs or at least\ndifferent heuristics from what cygwin itself uses).\n\nhttps://cygwin.com/cygwin-api/cygwin-functions.html#func-cygwin-path\n\n\nRegards,\nAchim.\n-- \n+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+\n\nSD adaptation for Waldorf microQ V2.22R2:\nhttp://Synth.Stromeko.net/Downloads.html#WaldorfSDada\n\n"},{"id":"364160","messageId":"878t1eqo2k.fsf@Rainer.invalid","threadId":"49846","inReplyTo":"xmqqtvk3tj45.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Achim Gratz","fromEmail":"stromeko@nexgo.de","sentAt":"2018-11-27T20:10:11Z","receivedAt":"2018-11-27T20:12:19Z","isPatch":true,"sender":{"key":"stromeko@nexgo.de","avatar":null},"body":"Junio C Hamano writes:\n> I wonder if it makes the rest of the code simpler if we stripped\n> things like /cygdrive/c here exactly the sam way as we strip C:\n> For that, has_dos_drive_prefix() needs to know /cygdrive/[a-z],\n> which may not be a bad thing, I guess.  Let's read on.\n\nThe cygdrive prefix can be configured by the user to something\narbitrarily different, so if you're hoping to simplify the string\nhandling this way you'll most likely be disappointed.  It is exactly\nthat fact that led to the introduction of /proc/cygdrive as an\nalternative prefix which doesn't depend on any configuration.\n\n\nRegards,\nAchim.\n-- \n+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+\n\nFactory and User Sound Singles for Waldorf Q+, Q and microQ:\nhttp://Synth.Stromeko.net/Downloads.html#WaldorfSounds\n\n"},{"id":"364184","messageId":"xmqq1s75u9im.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1811271352560.41@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-28T04:10:57Z","receivedAt":"2018-11-28T04:11:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Sorry, but I fail to see the point the last example wants to make.\n>\n> I agree. For me, the real test is this:\n>\n> me@work ~\n> $ cd /cygdrive\n>\n> me@work /cygdrive\n> $ ls\n> c  d\n>\n> So `/cygdrive` *is* a valid directory in Cygwin.\n\nThat supports the code that does not special case a path that begins\nwith /cygdrive/ and simply treats it as a full path and freely use\nrelative path, I guess.  Very good point.\n"},{"id":"364185","messageId":"xmqqwooxsuvf.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1811271346550.41@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-28T04:12:36Z","receivedAt":"2018-11-28T04:12:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> It takes a little folding and knotting of the brain to understand that\n> this `!skip_dos_drive_prefix(&pos)` has *nothing* to do with the comment\n> `unc paths` nor with the test whether the paths starts with two directory\n> separators.\n>\n> As a consequence, I would highly suggest to turn this into:\n>\n> \tif (skip_dos_drive_prefix(&pos))\n> \t\t; /* absolute path with DOS drive prefix */\n>   \t/* unc paths */\n> \telse if (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n>\n> That makes the code a lot easier to understand, and as a consequence a lot\n> harder to mess up in the future.\n\nExcellent.  With or without \"unc paths\" comment, the separation does\nmake the logic more clear.\n"},{"id":"364190","messageId":"1543384528-4498-1-git-send-email-houder@xs4all.nl","threadId":"49846","inReplyTo":"xmqq1s75u9im.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"J.H. van de Water","fromEmail":"houder@xs4all.nl","sentAt":"2018-11-28T05:55:28Z","receivedAt":"2018-11-28T05:55:38Z","isPatch":true,"sender":{"key":"houder@xs4all.nl","avatar":null},"body":"> > me@work /cygdrive\n> > $ ls\n> > c  d\n> >\n> > So `/cygdrive` *is* a valid directory in Cygwin.\n> \n> That supports the code that does not special case a path that begins\n> with /cygdrive/ and simply treats it as a full path and freely use\n> relative path, I guess.  Very good point.\n\nPlease read\n\n    https://cygwin.com/cygwin-ug-net/using.html#cygdrive\n    ( The cygdrive path prefix )\n\n.... you can access arbitary drives on your system by using the cygdrive path\nprefix. The default value for this prefix is /cygdrive ...\n....\n\nThe cygdrive prefix is a >>> virtual directory <<< under which all drives on\na system are subsumed ...\n....\n\nThe cygdrive prefix may be CHANGED in the fstab file as outlined above !!!!!\n....\n\nTo simplify scripting, Cygwin also provides a /proc/cygdrive symlink, ...\n\n=====\n"},{"id":"364198","messageId":"nycvar.QRO.7.76.6.1811280944520.41@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"1543384528-4498-1-git-send-email-houder@xs4all.nl","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-11-28T08:46:23Z","receivedAt":"2018-11-28T08:46:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi J.H.,\n\nOn Wed, 28 Nov 2018, J.H. van de Water wrote:\n\n> > > me@work /cygdrive\n> > > $ ls\n> > > c  d\n> > >\n> > > So `/cygdrive` *is* a valid directory in Cygwin.\n> > \n> > That supports the code that does not special case a path that begins\n> > with /cygdrive/ and simply treats it as a full path and freely use\n> > relative path, I guess.  Very good point.\n> \n> Please read\n> \n>     https://cygwin.com/cygwin-ug-net/using.html#cygdrive\n>     ( The cygdrive path prefix )\n> \n> .... you can access arbitary drives on your system by using the cygdrive path\n> prefix. The default value for this prefix is /cygdrive ...\n> ....\n> \n> The cygdrive prefix is a >>> virtual directory <<< under which all drives on\n> a system are subsumed ...\n> ....\n> \n> The cygdrive prefix may be CHANGED in the fstab file as outlined above !!!!!\n> ....\n> \n> To simplify scripting, Cygwin also provides a /proc/cygdrive symlink, ...\n> \n> =====\n\nThat's all very interesting, but I fail to see the relevance with regards\nto the issue at hand, namely whether to special-case `/cygdrive` as a\nspecial prefix that cannot be treated as directory in Git.\n\nI still maintain that it should not be special-cased, no matter whether it\nis a virtual directory or whether it can be renamed to `/jh-likes-cygwin`\nor whatever.\n\nCiao,\nDscho\n"},{"id":"364199","messageId":"327181b03df8abfd7194389c9bc21256@xs4all.nl","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1811280944520.41@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Houder","fromEmail":"houder@xs4all.nl","sentAt":"2018-11-28T09:01:56Z","receivedAt":"2018-11-28T09:02:02Z","isPatch":true,"sender":{"key":"houder@xs4all.nl","avatar":null},"body":"On 2018-11-28 09:46, Johannes Schindelin wrote:\n> Hi J.H.,\n> \n> On Wed, 28 Nov 2018, J.H. van de Water wrote:\n> \n>> > > me@work /cygdrive\n>> > > $ ls\n>> > > c  d\n>> > >\n>> > > So `/cygdrive` *is* a valid directory in Cygwin.\n>> >\n>> > That supports the code that does not special case a path that begins\n>> > with /cygdrive/ and simply treats it as a full path and freely use\n>> > relative path, I guess.  Very good point.\n>> \n>> Please read\n>> \n>>     https://cygwin.com/cygwin-ug-net/using.html#cygdrive\n>>     ( The cygdrive path prefix )\n>> \n>> .... you can access arbitary drives on your system by using the \n>> cygdrive path\n>> prefix. The default value for this prefix is /cygdrive ...\n>> ....\n>> \n>> The cygdrive prefix is a >>> virtual directory <<< under which all \n>> drives on\n>> a system are subsumed ...\n>> ....\n>> \n>> The cygdrive prefix may be CHANGED in the fstab file as outlined above \n>> !!!!!\n>> ....\n>> \n>> To simplify scripting, Cygwin also provides a /proc/cygdrive symlink, \n>> ...\n>> \n>> =====\n> \n> That's all very interesting, but I fail to see the relevance with \n> regards\n> to the issue at hand, namely whether to special-case `/cygdrive` as a\n> special prefix that cannot be treated as directory in Git.\n> \n> I still maintain that it should not be special-cased, no matter whether \n> it\n> is a virtual directory or whether it can be renamed to \n> `/jh-likes-cygwin`\n> or whatever.\n\nOk. Sorry about the noise.\n\n From your post I got the impression that you believed that there will \nalways\nbe a directory called /cygdrive on Cygwin.\n\nMy point: it can have a different name.\n\nRegards,\n\nHenri\n"},{"id":"364204","messageId":"nycvar.QRO.7.76.6.1811281033560.41@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"327181b03df8abfd7194389c9bc21256@xs4all.nl","subject":"Re: [PATCH v1/RFC 1/1] 'git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-11-28T09:35:33Z","receivedAt":"2018-11-28T09:35:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi J.H.\n\nOn Wed, 28 Nov 2018, Houder wrote:\n\n> On 2018-11-28 09:46, Johannes Schindelin wrote:\n> > \n> > On Wed, 28 Nov 2018, J.H. van de Water wrote:\n> > \n> > > > > me@work /cygdrive\n> > > > > $ ls\n> > > > > c  d\n> > > > >\n> > > > > So `/cygdrive` *is* a valid directory in Cygwin.\n> > > >\n> > > > That supports the code that does not special case a path that begins\n> > > > with /cygdrive/ and simply treats it as a full path and freely use\n> > > > relative path, I guess.  Very good point.\n> > > \n> > > Please read\n> > > \n> > >     https://cygwin.com/cygwin-ug-net/using.html#cygdrive\n> > >     ( The cygdrive path prefix )\n> > > \n> > > .... you can access arbitary drives on your system by using the cygdrive\n> > > path\n> > > prefix. The default value for this prefix is /cygdrive ...\n> > > ....\n> > > \n> > > The cygdrive prefix is a >>> virtual directory <<< under which all drives\n> > > on\n> > > a system are subsumed ...\n> > > ....\n> > > \n> > > The cygdrive prefix may be CHANGED in the fstab file as outlined above\n> > > !!!!!\n> > > ....\n> > > \n> > > To simplify scripting, Cygwin also provides a /proc/cygdrive symlink, ...\n> > > \n> > > =====\n> > \n> > That's all very interesting, but I fail to see the relevance with regards\n> > to the issue at hand, namely whether to special-case `/cygdrive` as a\n> > special prefix that cannot be treated as directory in Git.\n> > \n> > I still maintain that it should not be special-cased, no matter whether it\n> > is a virtual directory or whether it can be renamed to `/jh-likes-cygwin`\n> > or whatever.\n> \n> Ok. Sorry about the noise.\n> \n> From your post I got the impression that you believed that there will always\n> be a directory called /cygdrive on Cygwin.\n\nI know it can be different. In MSYS2 it is set to `/` via this line in\n`/etc/fstab`:\n\n\tnone / cygdrive binary,posix=0,noacl,user 0 0\n\nWhich is just to say that I am fully aware of the option to rename it.\n\n> My point: it can have a different name.\n\nIndeed.\n\nAnd whatever name you give it, Cygwin can handle it as if it were a\nregular directory. So we *must not* special-case it in Git.\n\nCiao,\nJohannes\n"},{"id":"364745","messageId":"20181207170458.9036-1-tboegi@web.de","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"[PATCH v2 2/3] offset_1st_component(), dos_drive_prefix() return size_t","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-12-07T17:04:58Z","receivedAt":"2018-12-07T17:05:03Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nChange the return value for offset_1st_component(),\nhas_dos_drive_prefix() and skip_dos_drive_prefix from int into size_t,\nwhich is the natural type for length of data in memory.\n\nWhile at it, remove possible \"parameter not used\" warnings in for the\nnon-Windows builds in git-compat-util.h\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n abspath.c             | 2 +-\n compat/mingw-cygwin.c | 6 +++---\n compat/mingw-cygwin.h | 4 ++--\n git-compat-util.h     | 8 +++++---\n setup.c               | 4 ++--\n 5 files changed, 13 insertions(+), 11 deletions(-)\n\ndiff --git a/abspath.c b/abspath.c\nindex 9857985329..12055a1d8f 100644\n--- a/abspath.c\n+++ b/abspath.c\n@@ -51,7 +51,7 @@ static void get_next_component(struct strbuf *next, struct strbuf *remaining)\n /* copies root part from remaining to resolved, canonicalizing it on the way */\n static void get_root_part(struct strbuf *resolved, struct strbuf *remaining)\n {\n-\tint offset = offset_1st_component(remaining->buf);\n+\tsize_t offset = offset_1st_component(remaining->buf);\n \n \tstrbuf_reset(resolved);\n \tstrbuf_add(resolved, remaining->buf, offset);\ndiff --git a/compat/mingw-cygwin.c b/compat/mingw-cygwin.c\nindex c63d7acb9c..5552c3ac20 100644\n--- a/compat/mingw-cygwin.c\n+++ b/compat/mingw-cygwin.c\n@@ -1,13 +1,13 @@\n #include \"../git-compat-util.h\"\n \n-int mingw_cygwin_skip_dos_drive_prefix(char **path)\n+size_t mingw_cygwin_skip_dos_drive_prefix(char **path)\n {\n-\tint ret = has_dos_drive_prefix(*path);\n+\tsize_t ret = has_dos_drive_prefix(*path);\n \t*path += ret;\n \treturn ret;\n }\n \n-int mingw_cygwin_offset_1st_component(const char *path)\n+size_t mingw_cygwin_offset_1st_component(const char *path)\n {\n \tchar *pos = (char *)path;\n \ndiff --git a/compat/mingw-cygwin.h b/compat/mingw-cygwin.h\nindex 66ccc909ae..0e8a0c9074 100644\n--- a/compat/mingw-cygwin.h\n+++ b/compat/mingw-cygwin.h\n@@ -1,6 +1,6 @@\n #define has_dos_drive_prefix(path) \\\n \t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n-int mingw_cygwin_skip_dos_drive_prefix(char **path);\n+size_t mingw_cygwin_skip_dos_drive_prefix(char **path);\n #define skip_dos_drive_prefix mingw_cygwin_skip_dos_drive_prefix\n static inline int mingw_cygwin_is_dir_sep(int c)\n {\n@@ -16,5 +16,5 @@ static inline char *mingw_cygwin_find_last_dir_sep(const char *path)\n \treturn ret;\n }\n #define find_last_dir_sep mingw_cygwin_find_last_dir_sep\n-int mingw_cygwin_offset_1st_component(const char *path);\n+size_t mingw_cygwin_offset_1st_component(const char *path);\n #define offset_1st_component mingw_cygwin_offset_1st_component\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7ece969b22..65eaaf0d50 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -355,16 +355,18 @@ static inline int noop_core_config(const char *var, const char *value, void *cb)\n #endif\n \n #ifndef has_dos_drive_prefix\n-static inline int git_has_dos_drive_prefix(const char *path)\n+static inline size_t git_has_dos_drive_prefix(const char *path)\n {\n+\t(void)path;\n \treturn 0;\n }\n #define has_dos_drive_prefix git_has_dos_drive_prefix\n #endif\n \n #ifndef skip_dos_drive_prefix\n-static inline int git_skip_dos_drive_prefix(char **path)\n+static inline size_t git_skip_dos_drive_prefix(char **path)\n {\n+\t(void)path;\n \treturn 0;\n }\n #define skip_dos_drive_prefix git_skip_dos_drive_prefix\n@@ -379,7 +381,7 @@ static inline int git_is_dir_sep(int c)\n #endif\n \n #ifndef offset_1st_component\n-static inline int git_offset_1st_component(const char *path)\n+static inline size_t git_offset_1st_component(const char *path)\n {\n \treturn is_dir_sep(path[0]);\n }\ndiff --git a/setup.c b/setup.c\nindex 1be5037f12..538bc1ff99 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -29,7 +29,7 @@ static int abspath_part_inside_repo(char *path)\n \tsize_t len;\n \tsize_t wtlen;\n \tchar *path0;\n-\tint off;\n+\tsize_t off;\n \tconst char *work_tree = get_git_work_tree();\n \n \tif (!work_tree)\n@@ -800,7 +800,7 @@ static const char *setup_bare_git_dir(struct strbuf *cwd, int offset,\n \t\t\t\t      struct repository_format *repo_fmt,\n \t\t\t\t      int *nongit_ok)\n {\n-\tint root_len;\n+\tsize_t root_len;\n \n \tif (check_repository_format_gently(\".\", repo_fmt, nongit_ok))\n \t\treturn NULL;\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"364746","messageId":"20181207170456.8994-1-tboegi@web.de","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"[PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-12-07T17:04:56Z","receivedAt":"2018-12-07T17:05:04Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nA regression for cygwin users was introduced with commit 05b458c,\n \"real_path: resolve symlinks by hand\".\n\nIn the the commit message we read:\n  The current implementation of real_path uses chdir() in order to resolve\n    symlinks.  Unfortunately this isn't thread-safe as chdir() affects a\n      process as a whole...\n\nThe old (and non-thread-save) OS calls chdir()/pwd() had been\nreplaced by a string operation.\nThe cygwin layer \"knows\" that \"C:\\cygwin\" is an absolute path,\nbut the new string operation does not.\n\n\"git clone <url> C:\\cygwin\\home\\USER\\repo\" fails like this:\nfatal: Invalid path '/home/USER/repo/C:\\cygwin\\home\\USER\\repo'\n\nThe solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\nis_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\nin the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n\nInstead of duplicating the code, it is extracted into compat/mingw-cygwin.[ch]\nSome need for refactoring and cleanup came up in the review, they are adressed\nin a seperate commit.\n\nReported-By: Steven Penny <svnpenn@gmail.com>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n compat/cygwin.c       | 19 -------------------\n compat/cygwin.h       |  2 --\n compat/mingw-cygwin.c | 28 ++++++++++++++++++++++++++++\n compat/mingw-cygwin.h | 20 ++++++++++++++++++++\n compat/mingw.c        | 29 +----------------------------\n compat/mingw.h        | 20 --------------------\n config.mak.uname      |  4 ++--\n git-compat-util.h     |  3 ++-\n 8 files changed, 53 insertions(+), 72 deletions(-)\n delete mode 100644 compat/cygwin.c\n delete mode 100644 compat/cygwin.h\n create mode 100644 compat/mingw-cygwin.c\n create mode 100644 compat/mingw-cygwin.h\n\ndiff --git a/compat/cygwin.c b/compat/cygwin.c\ndeleted file mode 100644\nindex b9862d606d..0000000000\n--- a/compat/cygwin.c\n+++ /dev/null\n@@ -1,19 +0,0 @@\n-#include \"../git-compat-util.h\"\n-#include \"../cache.h\"\n-\n-int cygwin_offset_1st_component(const char *path)\n-{\n-\tconst char *pos = path;\n-\t/* unc paths */\n-\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n-\t\t/* skip server name */\n-\t\tpos = strchr(pos + 2, '/');\n-\t\tif (!pos)\n-\t\t\treturn 0; /* Error: malformed unc path */\n-\n-\t\tdo {\n-\t\t\tpos++;\n-\t\t} while (*pos && pos[0] != '/');\n-\t}\n-\treturn pos + is_dir_sep(*pos) - path;\n-}\ndiff --git a/compat/cygwin.h b/compat/cygwin.h\ndeleted file mode 100644\nindex 8e52de4644..0000000000\n--- a/compat/cygwin.h\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-int cygwin_offset_1st_component(const char *path);\n-#define offset_1st_component cygwin_offset_1st_component\ndiff --git a/compat/mingw-cygwin.c b/compat/mingw-cygwin.c\nnew file mode 100644\nindex 0000000000..c63d7acb9c\n--- /dev/null\n+++ b/compat/mingw-cygwin.c\n@@ -0,0 +1,28 @@\n+#include \"../git-compat-util.h\"\n+\n+int mingw_cygwin_skip_dos_drive_prefix(char **path)\n+{\n+\tint ret = has_dos_drive_prefix(*path);\n+\t*path += ret;\n+\treturn ret;\n+}\n+\n+int mingw_cygwin_offset_1st_component(const char *path)\n+{\n+\tchar *pos = (char *)path;\n+\n+\t/* unc paths */\n+\tif (!skip_dos_drive_prefix(&pos) &&\n+\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n+\t\t/* skip server name */\n+\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n+\t\tif (!pos)\n+\t\t\treturn 0; /* Error: malformed unc path */\n+\n+\t\tdo {\n+\t\t\tpos++;\n+\t\t} while (*pos && !is_dir_sep(*pos));\n+\t}\n+\n+\treturn pos + is_dir_sep(*pos) - path;\n+}\ndiff --git a/compat/mingw-cygwin.h b/compat/mingw-cygwin.h\nnew file mode 100644\nindex 0000000000..66ccc909ae\n--- /dev/null\n+++ b/compat/mingw-cygwin.h\n@@ -0,0 +1,20 @@\n+#define has_dos_drive_prefix(path) \\\n+\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n+int mingw_cygwin_skip_dos_drive_prefix(char **path);\n+#define skip_dos_drive_prefix mingw_cygwin_skip_dos_drive_prefix\n+static inline int mingw_cygwin_is_dir_sep(int c)\n+{\n+\treturn c == '/' || c == '\\\\';\n+}\n+#define is_dir_sep mingw_cygwin_is_dir_sep\n+static inline char *mingw_cygwin_find_last_dir_sep(const char *path)\n+{\n+\tchar *ret = NULL;\n+\tfor (; *path; ++path)\n+\t\tif (is_dir_sep(*path))\n+\t\t\tret = (char *)path;\n+\treturn ret;\n+}\n+#define find_last_dir_sep mingw_cygwin_find_last_dir_sep\n+int mingw_cygwin_offset_1st_component(const char *path);\n+#define offset_1st_component mingw_cygwin_offset_1st_component\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 34b3880b29..038e96af9d 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -350,7 +350,7 @@ static inline int needs_hiding(const char *path)\n \t\treturn 0;\n \n \t/* We cannot use basename(), as it would remove trailing slashes */\n-\tmingw_skip_dos_drive_prefix((char **)&path);\n+\tmingw_cygwin_skip_dos_drive_prefix((char **)&path);\n \tif (!*path)\n \t\treturn 0;\n \n@@ -2275,33 +2275,6 @@ pid_t waitpid(pid_t pid, int *status, int options)\n \treturn -1;\n }\n \n-int mingw_skip_dos_drive_prefix(char **path)\n-{\n-\tint ret = has_dos_drive_prefix(*path);\n-\t*path += ret;\n-\treturn ret;\n-}\n-\n-int mingw_offset_1st_component(const char *path)\n-{\n-\tchar *pos = (char *)path;\n-\n-\t/* unc paths */\n-\tif (!skip_dos_drive_prefix(&pos) &&\n-\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n-\t\t/* skip server name */\n-\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n-\t\tif (!pos)\n-\t\t\treturn 0; /* Error: malformed unc path */\n-\n-\t\tdo {\n-\t\t\tpos++;\n-\t\t} while (*pos && !is_dir_sep(*pos));\n-\t}\n-\n-\treturn pos + is_dir_sep(*pos) - path;\n-}\n-\n int xutftowcsn(wchar_t *wcs, const char *utfs, size_t wcslen, int utflen)\n {\n \tint upos = 0, wpos = 0;\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 8c24ddaa3e..30d9fb3e36 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -443,32 +443,12 @@ HANDLE winansi_get_osfhandle(int fd);\n  * git specific compatibility\n  */\n \n-#define has_dos_drive_prefix(path) \\\n-\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n-int mingw_skip_dos_drive_prefix(char **path);\n-#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix\n-static inline int mingw_is_dir_sep(int c)\n-{\n-\treturn c == '/' || c == '\\\\';\n-}\n-#define is_dir_sep mingw_is_dir_sep\n-static inline char *mingw_find_last_dir_sep(const char *path)\n-{\n-\tchar *ret = NULL;\n-\tfor (; *path; ++path)\n-\t\tif (is_dir_sep(*path))\n-\t\t\tret = (char *)path;\n-\treturn ret;\n-}\n static inline void convert_slashes(char *path)\n {\n \tfor (; *path; path++)\n \t\tif (*path == '\\\\')\n \t\t\t*path = '/';\n }\n-#define find_last_dir_sep mingw_find_last_dir_sep\n-int mingw_offset_1st_component(const char *path);\n-#define offset_1st_component mingw_offset_1st_component\n #define PATH_SEP ';'\n extern char *mingw_query_user_email(void);\n #define query_user_email mingw_query_user_email\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 3ee7da0e23..9346f67922 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -187,7 +187,7 @@ ifeq ($(uname_O),Cygwin)\n \tUNRELIABLE_FSTAT = UnfortunatelyYes\n \tOBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo\n \tMMAP_PREVENTS_DELETE = UnfortunatelyYes\n-\tCOMPAT_OBJS += compat/cygwin.o\n+\tCOMPAT_OBJS += compat/mingw-cygwin.o\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n endif\n ifeq ($(uname_S),FreeBSD)\n@@ -526,7 +526,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tDEFAULT_HELP_FORMAT = html\n \tCOMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n-\tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n+\tCOMPAT_OBJS += compat/mingw.o compat/mingw-cygwin.o compat/winansi.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n \t\tcompat/win32/dirent.o\n \tBASIC_CFLAGS += -DWIN32 -DPROTECT_NTFS_DEFAULT=1\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 09b0102cae..7ece969b22 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -193,10 +193,11 @@\n #endif\n \n #if defined(__CYGWIN__)\n-#include \"compat/cygwin.h\"\n+#include \"compat/mingw-cygwin.h\"\n #endif\n #if defined(__MINGW32__)\n /* pull in Windows compatibility stuff */\n+#include \"compat/mingw-cygwin.h\"\n #include \"compat/mingw.h\"\n #elif defined(_MSC_VER)\n #include \"compat/msvc.h\"\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"364747","messageId":"20181207170500.9078-1-tboegi@web.de","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"[PATCH v2 3/3] Refactor mingw_cygwin_offset_1st_component()","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-12-07T17:05:00Z","receivedAt":"2018-12-07T17:05:06Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nThe Windows version of offset_1st_component() needs to hande 3 cases:\n- The path is an UNC path, starting with \"//\" or \"\\\\\\\\\".\n  Skip the servername and the name of the share.\n- The path is a DOS drive, starting with e.g. \"X:\"\n  The driver letter and the ':' must be skipped\n- The path is pointing to a subdirectory somewhere in the path and the\n  directory seperator needs to be skipped ('/' or '\\\\').\n\nRefactor the code to make it easier to read.\n\nSuggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n compat/mingw-cygwin.c | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/compat/mingw-cygwin.c b/compat/mingw-cygwin.c\nindex 5552c3ac20..c379a72775 100644\n--- a/compat/mingw-cygwin.c\n+++ b/compat/mingw-cygwin.c\n@@ -10,10 +10,8 @@ size_t mingw_cygwin_skip_dos_drive_prefix(char **path)\n size_t mingw_cygwin_offset_1st_component(const char *path)\n {\n \tchar *pos = (char *)path;\n-\n-\t/* unc paths */\n-\tif (!skip_dos_drive_prefix(&pos) &&\n-\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n+\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n+\t\t/* unc path */\n \t\t/* skip server name */\n \t\tpos = strpbrk(pos + 2, \"\\\\/\");\n \t\tif (!pos)\n@@ -22,7 +20,8 @@ size_t mingw_cygwin_offset_1st_component(const char *path)\n \t\tdo {\n \t\t\tpos++;\n \t\t} while (*pos && !is_dir_sep(*pos));\n+\t} else {\n+\t\tskip_dos_drive_prefix(&pos);\n \t}\n-\n \treturn pos + is_dir_sep(*pos) - path;\n }\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"364757","messageId":"nycvar.QRO.7.76.6.1812072251500.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"20181207170456.8994-1-tboegi@web.de","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-07T21:53:19Z","receivedAt":"2018-12-07T21:53:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Torsten,\n\nOn Fri, 7 Dec 2018, tboegi@web.de wrote:\n\n>  compat/mingw-cygwin.c | 28 ++++++++++++++++++++++++++++\n>  compat/mingw-cygwin.h | 20 ++++++++++++++++++++\n\nPlease use compat/win32/path.c (or .../path-utils.c) instead. This is not\nso much about MINGW or Cygwin or MSys or MSYS2 or Visual C++, but about\nWindows.\n\nThanks,\nJohannes\n"},{"id":"364761","messageId":"nycvar.QRO.7.76.6.1812072316290.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"20181207170500.9078-1-tboegi@web.de","subject":"Re: [PATCH v2 3/3] Refactor mingw_cygwin_offset_1st_component()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-07T22:18:52Z","receivedAt":"2018-12-07T22:19:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Torsten,\n\nOn Fri, 7 Dec 2018, tboegi@web.de wrote:\n\n> diff --git a/compat/mingw-cygwin.c b/compat/mingw-cygwin.c\n> index 5552c3ac20..c379a72775 100644\n> --- a/compat/mingw-cygwin.c\n> +++ b/compat/mingw-cygwin.c\n> @@ -10,10 +10,8 @@ size_t mingw_cygwin_skip_dos_drive_prefix(char **path)\n>  size_t mingw_cygwin_offset_1st_component(const char *path)\n>  {\n>  \tchar *pos = (char *)path;\n> -\n> -\t/* unc paths */\n\nThis comment is still useful (and now even more correct), and should stay.\n\n> -\tif (!skip_dos_drive_prefix(&pos) &&\n> -\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n> +\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n> +\t\t/* unc path */\n>  \t\t/* skip server name */\n>  \t\tpos = strpbrk(pos + 2, \"\\\\/\");\n>  \t\tif (!pos)\n> @@ -22,7 +20,8 @@ size_t mingw_cygwin_offset_1st_component(const char *path)\n>  \t\tdo {\n>  \t\t\tpos++;\n>  \t\t} while (*pos && !is_dir_sep(*pos));\n> +\t} else {\n> +\t\tskip_dos_drive_prefix(&pos);\n>  \t}\n> -\n\nWhy remove this empty line? It structures the code quite nicely.\n\nThe rest looks correct to me,\nJohannes\n\n>  \treturn pos + is_dir_sep(*pos) - path;\n>  }\n> -- \n> 2.19.0.271.gfe8321ec05\n> \n> \n"},{"id":"364783","messageId":"CAAXzdLVTjCVDmBik-j9B_Z_2wgSj=_6baqmjmGEGBFOsjkyOsw@mail.gmail.com","threadId":"49846","inReplyTo":"20181207170456.8994-1-tboegi@web.de","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-12-08T00:49:29Z","receivedAt":"2018-12-08T00:49:30Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Fri, Dec 7, 2018 at 11:04 AM wrote:\n> The solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\n> is_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\n> in the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n>\n> Instead of duplicating the code, it is extracted into compat/mingw-cygwin.[ch]\n> Some need for refactoring and cleanup came up in the review, they are adressed\n> in a seperate commit.\n\ni have applied the 3 patches against current master, and my original test\npasses, so looks good to me.\n\nhowever like Johannes i take issue with the naming. as he said \"mingw-cygwin\"\nreally isnt appropriate. ideally it would be \"windows.h\", but as that is\nconspicuously in use, something like these:\n\n- pc-windows\n- pc-win\n- win\n\ni disagree with him on using \"win32\" - that doesnt really make sense, as\nobviously you can compile 64-bit Git for Windows. if you wanted to go that route\nyou would want to use something like:\n\n- windows-api\n- win-api\n- winapi\n\nfurther - i disagree with the \"DOS\" moniker being used at all. DOS is a defunkt\noperating system that i dont think Git has *ever* supported, so it doesnt make\nsense to be referring to it this way. again, a more approriate name would be\nsomething like \"win_drive_prefix\".\n"},{"id":"364802","messageId":"20181208151109.2097-1-tboegi@web.de","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"[PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-12-08T15:11:09Z","receivedAt":"2018-12-08T15:11:16Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nA regression for cygwin users was introduced with commit 05b458c,\n \"real_path: resolve symlinks by hand\".\n\nIn the the commit message we read:\n  The current implementation of real_path uses chdir() in order to resolve\n    symlinks.  Unfortunately this isn't thread-safe as chdir() affects a\n      process as a whole...\n\nThe old (and non-thread-save) OS calls chdir()/pwd() had been\nreplaced by a string operation.\nThe cygwin layer \"knows\" that \"C:\\cygwin\" is an absolute path,\nbut the new string operation does not.\n\n\"git clone <url> C:\\cygwin\\home\\USER\\repo\" fails like this:\nfatal: Invalid path '/home/USER/repo/C:\\cygwin\\home\\USER\\repo'\n\nThe solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\nis_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\nin the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n\nExtract the needed code into compat/win32/path-utils.[ch] and use it\nfor cygwin as well.\n\nReported-by: Steven Penny <svnpenn@gmail.com>\nHelped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nChanges since V2:\n- Settled on a better name:\n  The common code is in compat/win32/path-utils.c/h\n- Skip the 2 patches which \"only\" do a cleanup (for a moment)\n  put those cleanups onto the \"todo stack\".\n- The \"DOS\" moniker is still used for 2 reasons:\n  Windows inherited the \"drive letter\" concept from DOS,\n  and everybody (tm) familar with the code and the path handling\n  in Git is used to that wording.\n  Even if there was a better name, it needed to be addressed\n  in a patch series different from this one.\n  Here I want to fix a reported regression.\n   \nAnd, before any cleanup is done, I sould like to ask if anybody\ncan build the code with VS and confirm that it works, please ?\n\nThanks for the reviews, testing and comment.\n\ncompat/cygwin.c           | 19 -------------------\n compat/cygwin.h           |  2 --\n compat/mingw.c            | 29 +----------------------------\n compat/mingw.h            | 20 --------------------\n compat/win32/path-utils.c | 28 ++++++++++++++++++++++++++++\n compat/win32/path-utils.h | 20 ++++++++++++++++++++\n config.mak.uname          |  3 ++-\n git-compat-util.h         |  3 ++-\n 8 files changed, 53 insertions(+), 71 deletions(-)\n delete mode 100644 compat/cygwin.c\n delete mode 100644 compat/cygwin.h\n create mode 100644 compat/win32/path-utils.c\n create mode 100644 compat/win32/path-utils.h\n\ndiff --git a/compat/cygwin.c b/compat/cygwin.c\ndeleted file mode 100644\nindex b9862d606d..0000000000\n--- a/compat/cygwin.c\n+++ /dev/null\n@@ -1,19 +0,0 @@\n-#include \"../git-compat-util.h\"\n-#include \"../cache.h\"\n-\n-int cygwin_offset_1st_component(const char *path)\n-{\n-\tconst char *pos = path;\n-\t/* unc paths */\n-\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n-\t\t/* skip server name */\n-\t\tpos = strchr(pos + 2, '/');\n-\t\tif (!pos)\n-\t\t\treturn 0; /* Error: malformed unc path */\n-\n-\t\tdo {\n-\t\t\tpos++;\n-\t\t} while (*pos && pos[0] != '/');\n-\t}\n-\treturn pos + is_dir_sep(*pos) - path;\n-}\ndiff --git a/compat/cygwin.h b/compat/cygwin.h\ndeleted file mode 100644\nindex 8e52de4644..0000000000\n--- a/compat/cygwin.h\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-int cygwin_offset_1st_component(const char *path);\n-#define offset_1st_component cygwin_offset_1st_component\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 34b3880b29..27e397f268 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -350,7 +350,7 @@ static inline int needs_hiding(const char *path)\n \t\treturn 0;\n \n \t/* We cannot use basename(), as it would remove trailing slashes */\n-\tmingw_skip_dos_drive_prefix((char **)&path);\n+\twin_path_utils_skip_dos_drive_prefix((char **)&path);\n \tif (!*path)\n \t\treturn 0;\n \n@@ -2275,33 +2275,6 @@ pid_t waitpid(pid_t pid, int *status, int options)\n \treturn -1;\n }\n \n-int mingw_skip_dos_drive_prefix(char **path)\n-{\n-\tint ret = has_dos_drive_prefix(*path);\n-\t*path += ret;\n-\treturn ret;\n-}\n-\n-int mingw_offset_1st_component(const char *path)\n-{\n-\tchar *pos = (char *)path;\n-\n-\t/* unc paths */\n-\tif (!skip_dos_drive_prefix(&pos) &&\n-\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n-\t\t/* skip server name */\n-\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n-\t\tif (!pos)\n-\t\t\treturn 0; /* Error: malformed unc path */\n-\n-\t\tdo {\n-\t\t\tpos++;\n-\t\t} while (*pos && !is_dir_sep(*pos));\n-\t}\n-\n-\treturn pos + is_dir_sep(*pos) - path;\n-}\n-\n int xutftowcsn(wchar_t *wcs, const char *utfs, size_t wcslen, int utflen)\n {\n \tint upos = 0, wpos = 0;\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 8c24ddaa3e..30d9fb3e36 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -443,32 +443,12 @@ HANDLE winansi_get_osfhandle(int fd);\n  * git specific compatibility\n  */\n \n-#define has_dos_drive_prefix(path) \\\n-\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n-int mingw_skip_dos_drive_prefix(char **path);\n-#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix\n-static inline int mingw_is_dir_sep(int c)\n-{\n-\treturn c == '/' || c == '\\\\';\n-}\n-#define is_dir_sep mingw_is_dir_sep\n-static inline char *mingw_find_last_dir_sep(const char *path)\n-{\n-\tchar *ret = NULL;\n-\tfor (; *path; ++path)\n-\t\tif (is_dir_sep(*path))\n-\t\t\tret = (char *)path;\n-\treturn ret;\n-}\n static inline void convert_slashes(char *path)\n {\n \tfor (; *path; path++)\n \t\tif (*path == '\\\\')\n \t\t\t*path = '/';\n }\n-#define find_last_dir_sep mingw_find_last_dir_sep\n-int mingw_offset_1st_component(const char *path);\n-#define offset_1st_component mingw_offset_1st_component\n #define PATH_SEP ';'\n extern char *mingw_query_user_email(void);\n #define query_user_email mingw_query_user_email\ndiff --git a/compat/win32/path-utils.c b/compat/win32/path-utils.c\nnew file mode 100644\nindex 0000000000..6cb9a6a745\n--- /dev/null\n+++ b/compat/win32/path-utils.c\n@@ -0,0 +1,28 @@\n+#include \"../../git-compat-util.h\"\n+\n+int win_path_utils_skip_dos_drive_prefix(char **path)\n+{\n+\tint ret = has_dos_drive_prefix(*path);\n+\t*path += ret;\n+\treturn ret;\n+}\n+\n+int win_path_utils_offset_1st_component(const char *path)\n+{\n+\tchar *pos = (char *)path;\n+\n+\t/* unc paths */\n+\tif (!skip_dos_drive_prefix(&pos) &&\n+\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n+\t\t/* skip server name */\n+\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n+\t\tif (!pos)\n+\t\t\treturn 0; /* Error: malformed unc path */\n+\n+\t\tdo {\n+\t\t\tpos++;\n+\t\t} while (*pos && !is_dir_sep(*pos));\n+\t}\n+\n+\treturn pos + is_dir_sep(*pos) - path;\n+}\ndiff --git a/compat/win32/path-utils.h b/compat/win32/path-utils.h\nnew file mode 100644\nindex 0000000000..c931b2a890\n--- /dev/null\n+++ b/compat/win32/path-utils.h\n@@ -0,0 +1,20 @@\n+#define has_dos_drive_prefix(path) \\\n+\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n+int win_path_utils_skip_dos_drive_prefix(char **path);\n+#define skip_dos_drive_prefix win_path_utils_skip_dos_drive_prefix\n+static inline int win_path_utils_is_dir_sep(int c)\n+{\n+\treturn c == '/' || c == '\\\\';\n+}\n+#define is_dir_sep win_path_utils_is_dir_sep\n+static inline char *win_path_utils_find_last_dir_sep(const char *path)\n+{\n+\tchar *ret = NULL;\n+\tfor (; *path; ++path)\n+\t\tif (is_dir_sep(*path))\n+\t\t\tret = (char *)path;\n+\treturn ret;\n+}\n+#define find_last_dir_sep win_path_utils_find_last_dir_sep\n+int win_path_utils_offset_1st_component(const char *path);\n+#define offset_1st_component win_path_utils_offset_1st_component\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 3ee7da0e23..60876e26f4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -187,7 +187,7 @@ ifeq ($(uname_O),Cygwin)\n \tUNRELIABLE_FSTAT = UnfortunatelyYes\n \tOBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo\n \tMMAP_PREVENTS_DELETE = UnfortunatelyYes\n-\tCOMPAT_OBJS += compat/cygwin.o\n+\tCOMPAT_OBJS += compat/win32/path-utils.o\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n endif\n ifeq ($(uname_S),FreeBSD)\n@@ -527,6 +527,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tCOMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n+\t\tcompat/win32/path-utils.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n \t\tcompat/win32/dirent.o\n \tBASIC_CFLAGS += -DWIN32 -DPROTECT_NTFS_DEFAULT=1\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 09b0102cae..5702556c89 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -193,10 +193,11 @@\n #endif\n \n #if defined(__CYGWIN__)\n-#include \"compat/cygwin.h\"\n+#include \"compat/win32/path-utils.h\"\n #endif\n #if defined(__MINGW32__)\n /* pull in Windows compatibility stuff */\n+#include \"compat/win32/path-utils.h\"\n #include \"compat/mingw.h\"\n #elif defined(_MSC_VER)\n #include \"compat/msvc.h\"\n-- \n2.19.0.271.gfe8321ec05\n\n"},{"id":"364806","messageId":"CAAXzdLXrFNz=bbyZrx=N6D38aWpATLhQS4Q8qWmv89cuvrdNTg@mail.gmail.com","threadId":"49846","inReplyTo":"20181208151109.2097-1-tboegi@web.de","subject":"Re: [PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-12-08T16:24:46Z","receivedAt":"2018-12-08T16:24:47Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Sat, Dec 8, 2018 at 9:11 AM wrote:\n> Changes since V2:\n\nlatest patch still fixes original issue - thanks\n\n> - Settled on a better name:\n>   The common code is in compat/win32/path-utils.c/h\n>   [...]\n> - The \"DOS\" moniker is still used for 2 reasons:\n>   Windows inherited the \"drive letter\" concept from DOS,\n>   and everybody (tm) familar with the code and the path handling\n>   in Git is used to that wording.\n>   Even if there was a better name, it needed to be addressed\n>   in a patch series different from this one.\n>   Here I want to fix a reported regression.\n\ni still disagree with this - but i understand if naming argument is out of scope\nfor thread\n\n> And, before any cleanup is done, I sould like to ask if anybody\n> can build the code with VS and confirm that it works, please ?\n\nsorry but i am decidedly *not* interested in doing this. i use cygwin\nspecifically so that i can avoid VS. hopefully someone else will be able to\ntest. cheers\n"},{"id":"364829","messageId":"xmqqk1kj5vhg.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"20181208151109.2097-1-tboegi@web.de","subject":"Re: [PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-09T01:39:39Z","receivedAt":"2018-12-09T01:39:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tboegi@web.de writes:\n\n> - The \"DOS\" moniker is still used for 2 reasons:\n>   Windows inherited the \"drive letter\" concept from DOS,\n>   and everybody (tm) familar with the code and the path handling\n>   in Git is used to that wording.\n\nYeah, for the same reason as win32 can refer to their API that is\nused on platforms that are 64-bit, the fact that the \"drive letter\"\nconcept came from DOS is so widely ingrained, I do not think it is a\nbeter change to deviate from it.\n\n> And, before any cleanup is done, I sould like to ask if anybody\n> can build the code with VS and confirm that it works, please ?\n\nYup, that is much more important.\n\nThanks.\n"},{"id":"364909","messageId":"nycvar.QRO.7.76.6.1812100931390.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"20181208151109.2097-1-tboegi@web.de","subject":"Re: [PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-10T08:32:03Z","receivedAt":"2018-12-10T08:32:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Torsten,\n\nOn Sat, 8 Dec 2018, tboegi@web.de wrote:\n\n> And, before any cleanup is done, I sould like to ask if anybody\n> can build the code with VS and confirm that it works, please ?\n\nCan you give me an easy-to-fetch branch?\n\nThanks,\nDscho\n"},{"id":"364912","messageId":"nycvar.QRO.7.76.6.1812100938140.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"CAAXzdLVTjCVDmBik-j9B_Z_2wgSj=_6baqmjmGEGBFOsjkyOsw@mail.gmail.com","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-10T08:46:38Z","receivedAt":"2018-12-10T08:46:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Steven,\n\nplease stop dropping me from the Cc: list. Thanks.\n\nOn Fri, 7 Dec 2018, Steven Penny wrote:\n\n> On Fri, Dec 7, 2018 at 11:04 AM wrote:\n>\n> > The solution is to implement has_dos_drive_prefix(),\n> > skip_dos_drive_prefix() is_dir_sep(), offset_1st_component() and\n> > convert_slashes() for cygwin in the same way as it is done in 'Git for\n> > Windows' in compat/mingw.[ch]\n> >\n> > Instead of duplicating the code, it is extracted into\n> > compat/mingw-cygwin.[ch] Some need for refactoring and cleanup came up\n> > in the review, they are adressed in a seperate commit.\n> \n> i have applied the 3 patches against current master, and my original\n> test passes, so looks good to me.\n> \n> however like Johannes i take issue with the naming. as he said \"mingw-cygwin\"\n> really isnt appropriate. ideally it would be \"windows.h\", but as that is\n> conspicuously in use, something like these:\n> \n> - pc-windows\n> - pc-win\n> - win\n\nI find all of those horrible.\n\n> i disagree with him on using \"win32\" - that doesnt really make sense,\n\n... except if you take into account that this has been our convention for,\nwhat, almost 9 years (since 44626dc7d5 (MSVC: Windows-native\nimplementation for subset of Pthreads API, 2010-01-15), to be precise)? In\nthat case, it makes a ton of sense, and one might be tempted to ask who\nthe person wanting to change that thinks they are...\n\n> as obviously you can compile 64-bit Git for Windows. if you wanted to go\n> that route you would want to use something like:\n> \n> - windows-api\n> - win-api\n> - winapi\n> \n> further - i disagree with the \"DOS\" moniker being used at all. DOS is a\n> defunkt operating system that i dont think Git has *ever* supported, so\n> it doesnt make sense to be referring to it this way. again, a more\n> approriate name would be something like \"win_drive_prefix\".\n\nYou may disagree all you want, but given that Torsten has been a lot more\nactive on this code than you have been so far, I'll go with Torsten's\ntaste. Which incidentally happens to match my tastes, so that's an added\nbonus.\n\nCiao,\nJohannes\n"},{"id":"364918","messageId":"CAAXzdLUKhCfvqdvsPryeMGJ2ttJxof4sUcyTx-xd5p2BaoryiQ@mail.gmail.com","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1812100938140.43@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-12-10T12:45:58Z","receivedAt":"2018-12-10T12:46:09Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Mon, Dec 10, 2018 at 2:46 AM Johannes Schindelin wrote:\n> please stop dropping me from the Cc: list. Thanks.\n\ni dropped you specifically because i knew you were going to flame like you just\ndid below. oh well, i guess you cant avoid the inevitable.\n\n> > - pc-windows\n> > - pc-win\n> > - win\n>\n> I find all of those horrible.\n\nthey arent great, but \"win32\" simply isnt valid. as soon as we started compiling\nfor 64-bit and using 64-bit APIs it didnt make sense to keep using it. if you\nwant to refer to all versions of the Microsoft OS you say \"Windows\", not\n\"Windows XP\", as that would be confusing for people using Windows 10. In the\nsame vein you shouldnt refer to the current Windows API as \"Win32\" because its\nno longer just 32-bit.\n\n> ... except if you take into account that this has been our convention for,\n> what, almost 9 years (since 44626dc7d5 (MSVC: Windows-native\n> implementation for subset of Pthreads API, 2010-01-15), to be precise)? In\n> that case, it makes a ton of sense, and one might be tempted to ask who\n> the person wanting to change that thinks they are...\n\n\"That's the way it's always been done\" is not a good reason to keep doing\nsomething. I would say the justification goes the other way, as to why we should\nkeep using an old moniker when its past making sense.\n\n> You may disagree all you want, but given that Torsten has been a lot more\n> active on this code than you have been so far, I'll go with Torsten's\n> taste. Which incidentally happens to match my tastes, so that's an added\n> bonus.\n\nin the end i dont really care what your taste is, or Torsten for that matter. I\ncare that the issue be fixed.\n"},{"id":"365039","messageId":"20181211061204.GA1130@tor.lan","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1812100931390.43@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-12-11T06:12:04Z","receivedAt":"2018-12-11T06:12:08Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Mon, Dec 10, 2018 at 09:32:03AM +0100, Johannes Schindelin wrote:\n> Hi Torsten,\n> \n> On Sat, 8 Dec 2018, tboegi@web.de wrote:\n> \n> > And, before any cleanup is done, I sould like to ask if anybody\n> > can build the code with VS and confirm that it works, please ?\n> \n> Can you give me an easy-to-fetch branch?\n> \n> Thanks,\n> Dscho\n\n@Dscho: The branch should be here:\n  https://github.com/tboegi/git/tree/tb.181208_0844_cygwin-dos-drive\n  (or fetch it from Junio, please see below:)\n\n@Junio:\n  Please keep tb/use-common-win32-pathfuncs-on-cygwin\n  in pu for a while. I need to send a V4 to fix t5601 for cygwin.\n \n"},{"id":"365076","messageId":"nycvar.QRO.7.76.6.1812111420570.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"20181211061204.GA1130@tor.lan","subject":"Re: [PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-11T13:28:43Z","receivedAt":"2018-12-11T13:28:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Torsten,\n\nOn Tue, 11 Dec 2018, Torsten Bögershausen wrote:\n\n> On Mon, Dec 10, 2018 at 09:32:03AM +0100, Johannes Schindelin wrote:\n> > \n> > On Sat, 8 Dec 2018, tboegi@web.de wrote:\n> > \n> > > And, before any cleanup is done, I sould like to ask if anybody\n> > > can build the code with VS and confirm that it works, please ?\n> > \n> > Can you give me an easy-to-fetch branch?\n> > \n> > Thanks,\n> > Dscho\n> \n> @Dscho: The branch should be here:\n>   https://github.com/tboegi/git/tree/tb.181208_0844_cygwin-dos-drive\n>   (or fetch it from Junio, please see below:)\n\nI fetched it from you, as Junio frequently applies patches anywhere except\nwhere they were developed. I'd rather see what you see. For the record,\nthis is the commit I tested: cc1e08eeb83b.\n\nIt builds fine here, and some cursory tests reveal that it works as\nadvertised (I ran t0001, t0060 and t5580).\n\nHowever.\n\nCan you please replace the rather unnecessary, very, very long\n`win_path_utils_` function name prefix by the much better prefix `win32_`,\nto keep in line with the current, already existing, surrounding files'\nconvention? Thanks a bunch.\n\nCiao,\nDscho\n\n> @Junio:\n>   Please keep tb/use-common-win32-pathfuncs-on-cygwin\n>   in pu for a while. I need to send a V4 to fix t5601 for cygwin.\n>  \n> "},{"id":"365077","messageId":"nycvar.QRO.7.76.6.1812111429320.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"CAAXzdLUKhCfvqdvsPryeMGJ2ttJxof4sUcyTx-xd5p2BaoryiQ@mail.gmail.com","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-11T13:39:09Z","receivedAt":"2018-12-11T13:39:13Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Steven,\n\nOn Mon, 10 Dec 2018, Steven Penny wrote:\n\n> On Mon, Dec 10, 2018 at 2:46 AM Johannes Schindelin wrote:\n> > please stop dropping me from the Cc: list. Thanks.\n> \n> i dropped you specifically because i knew you were going to flame like\n> you just did below. oh well, i guess you cant avoid the inevitable.\n\nI have no intention of flaming anybody. That is simply a\nmisrepresentation.\n\n> > > - pc-windows\n> > > - pc-win\n> > > - win\n> >\n> > I find all of those horrible.\n> \n> they arent great, but \"win32\" simply isnt valid.\n\nIt is a long established convention to talk about the Win32 API as the set\nof functions developed for Windows NT and backported to Windows 95.\n\nThere is no benefit in abandoning that convention just to please you.\n\n> > ... except if you take into account that this has been our convention\n> > for, what, almost 9 years (since 44626dc7d5 (MSVC: Windows-native\n> > implementation for subset of Pthreads API, 2010-01-15), to be\n> > precise)? In that case, it makes a ton of sense, and one might be\n> > tempted to ask who the person wanting to change that thinks they\n> > are...\n> \n> \"That's the way it's always been done\" is not a good reason to keep\n> doing something. I would say the justification goes the other way, as to\n> why we should keep using an old moniker when its past making sense.\n\nIf you want to change something that has been in use for a long time, you\nhave to have good reasons. None of your arguments convinces me so far that\nyou have any good reason to change these.\n\nLet's hear some good argument in a well-prepared patch, or alternatively\nlet's just not discuss these hypotheticals anymore.\n\n> > You may disagree all you want, but given that Torsten has been a lot\n> > more active on this code than you have been so far, I'll go with\n> > Torsten's taste. Which incidentally happens to match my tastes, so\n> > that's an added bonus.\n> \n> in the end i dont really care what your taste is, or Torsten for that\n> matter. I care that the issue be fixed.\n\nIf anyone truly cares about an issue to be fixed, I would expect more\nassisting, and less distracting, to do wonders.\n\nCiao,\nJohannes\n"},{"id":"365111","messageId":"20181211185538.GA23362@tor.lan","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1812111420570.43@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v3 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2018-12-11T18:55:38Z","receivedAt":"2018-12-11T18:55:44Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"> \n> Can you please replace the rather unnecessary, very, very long\n> `win_path_utils_` function name prefix by the much better prefix `win32_`,\n> to keep in line with the current, already existing, surrounding files'\n> convention? Thanks a bunch.\n> \n\nThat makes sense - thanks for the suggestion & testing.\n"},{"id":"365148","messageId":"CAAXzdLU7dJGOW689tDkYuRYko1zYHXMcj_2PaVa0qStYA7ELNw@mail.gmail.com","threadId":"49846","inReplyTo":"nycvar.QRO.7.76.6.1812111429320.43@tvgsbejvaqbjf.bet","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-12-12T00:42:34Z","receivedAt":"2018-12-12T00:42:41Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Tue, Dec 11, 2018 at 7:39 AM Johannes Schindelin wrote:\n> I have no intention of flaming anybody. That is simply a\n> misrepresentation.\n\nyou may see yourself \"through a glass darkly\", but i dont. this language is not\nconstructive:\n\n> > - pc-windows\n> > - pc-win\n> > - win\n>\n> I find all of those horrible.\n\none windows triplet in use is \"x86_64-pc-windows\", used by Rust:\n\nhttps://forge.rust-lang.org/other-installation-methods.html\n\nwhich is how i came about my suggestions - again they arent great but they arent\nmisleading as \"Win32\" is.\n\n> It is a long established convention to talk about the Win32 API as the set\n> of functions developed for Windows NT and backported to Windows 95.\n>\n> There is no benefit in abandoning that convention just to please you.\n\nQuoting from Wikipedia (emphasis mine):\n\n> The **Windows API**, informally **WinAPI**, is Microsoft's core set of\n> application programming interfaces (APIs) available in the Microsoft Windows\n> operating systems. The name **Windows API** collectively refers to several\n> different platform implementations that are often referred to by their own\n> names (for example, **Win32** API)\n\nand:\n\n> Microsoft eventually changed the name of the then current **Win32** API family\n> into **Windows API**, and made it into a catch-all term for both past and\n> future API versions.\n\nhttp://wikipedia.org/wiki/Windows_API\n\nand quoting directly from Microsoft:\n\n> The **Windows API** can be used in all Windows-based desktop applications, and\n> the same functions are generally supported on 32-bit and 64-bit Windows.\n\nhttp://docs.microsoft.com/windows/desktop/apiindex/api-index-portal\n\nSo again, \"Win32\" refers specifically to the old 32-bit only version of the API,\nwhile:\n\n- windows-api\n- win-api\n- winapi\n\nrefer to the current version.\n\n> If you want to change something that has been in use for a long time, you\n> have to have good reasons. None of your arguments convinces me so far that\n> you have any good reason to change these.\n\ni am certainly not interested in convincing you. i figured you wouldve gleaned\nthis from the fact that i removed you from the CC. Nevertheless, see above\nlinks.\n\n> If anyone truly cares about an issue to be fixed, I would expect more\n> assisting, and less distracting, to do wonders.\n\nhmm:\n\n- http://public-inbox.org/git/CAAXzdLXSJU5bC_D1Q_gCWqKG7mcdcAvRkiYzano-VsrRRxazDQ@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLXmJ1YKiTF17b=ZfkM3HtJCNkvVMQNU=riW8R42VLid_Q@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLWByGC+B_XdDiJwounoPgMAsMq=EuOSx9bdV-f5vQUhnA@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLXCEeZdkCXT+-0n=Fn7_=Nz5cm+6xr0w-cd6B1om028uA@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLU3dsCabgYKnD9c7iWZcXx1cfO3tisJ7r0dNjiiTHk1mA@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLWBSD5coxqbyRN_d9B1e4AA-Q6VQ7iRo8BPuhBKDicMRQ@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLX4jU7+i1W1A_Q1LpPFa1D4FYVPW5rcMnqr_tDHEJn+tw@mail.gmail.com\n- http://public-inbox.org/git/CAAXzdLWtDw09umyr23qZkv2jQ6_mTeFXbktgb-f6S2w6Zf1Egg@mail.gmail.com\n"},{"id":"365150","messageId":"CABPp-BHqJ_Dqpi-N-GVu9difvh-SnD1SZ2-SqaG0ctu5fBX-Tw@mail.gmail.com","threadId":"49846","inReplyTo":"CAAXzdLVTjCVDmBik-j9B_Z_2wgSj=_6baqmjmGEGBFOsjkyOsw@mail.gmail.com","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2018-12-12T03:47:40Z","receivedAt":"2018-12-12T03:47:54Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Fri, Dec 7, 2018 at 4:51 PM Steven Penny <svnpenn@gmail.com> wrote:\n>\n> On Fri, Dec 7, 2018 at 11:04 AM wrote:\n> > The solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\n> > is_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\n> > in the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n> >\n> > Instead of duplicating the code, it is extracted into compat/mingw-cygwin.[ch]\n> > Some need for refactoring and cleanup came up in the review, they are adressed\n> > in a seperate commit.\n>\n> i have applied the 3 patches against current master, and my original test\n> passes, so looks good to me.\n>\n> however like Johannes i take issue with the naming. as he said \"mingw-cygwin\"\n> really isnt appropriate. ideally it would be \"windows.h\", but as that is\n> conspicuously in use, something like these:\n>\n> - pc-windows\n> - pc-win\n> - win\n>\n> i disagree with him on using \"win32\" - that doesnt really make sense, as\n> obviously you can compile 64-bit Git for Windows. if you wanted to go that route\n> you would want to use something like:\n>\n> - windows-api\n> - win-api\n> - winapi\n>\n> further - i disagree with the \"DOS\" moniker being used at all. DOS is a defunkt\n> operating system that i dont think Git has *ever* supported, so it doesnt make\n> sense to be referring to it this way. again, a more approriate name would be\n> something like \"win_drive_prefix\".\n\nYou seem to want internal function and filenames to be based on the\nproduct or marketing names of currently targetted systems.  I don't\nsee why this is desirable; could you explain why it is?\n\nI admit that I seem to see things more from Dscho's angle.  However, I\nknow much less about Windows than either of you.  Perhaps my best\nunderstanding of the situation might help, limited as it is:\n  - Using currently targetted system names means future code churn --\nwe may have to rename functions and files for absolutely no useful\ngain, muddying the history, making it harder for developers to\nremember how to find things, etc., simply because an external party\nrenamed their libraries or introduced a new product.\n  - For people less familiar with windows,\n\"windows-api/win-api/winapi\" and \"win_drive_prefix\" may sound like\nsomething only available in newer systems, making them wonder if the\nfile name or function name is referring to some new windows concept\nthey are unfamiliar with\n  - Mentioning an anchor point where the relevant concept originally\ntargetted or where it came from (win32/path.c, dos_drive_prefix)\navoids or greatly reduces both problems.\n\n\nI'm worried based on other emails in this thread that there is a\nfundamental difference in frame of reference leading to a\nmisunderstanding about rationale for naming, and worse that folks\nmight not even realize where the misunderstanding is coming from,\nattributing it to different motives rather than different frames of\nreference.  If that's true, I hope this email can begin the process of\nclearing up the differences of understanding.  If I'm wrong, then I\napologize for the noise; just ignore me.\n\nBest wishes,\nElijah\n"},{"id":"365156","messageId":"be24f331-5c8f-954d-e6f5-d5b09ee4e5f3@kdbg.org","threadId":"49846","inReplyTo":"CAAXzdLU7dJGOW689tDkYuRYko1zYHXMcj_2PaVa0qStYA7ELNw@mail.gmail.com","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2018-12-12T07:29:46Z","receivedAt":"2018-12-12T07:29:50Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 12.12.18 um 01:42 schrieb Steven Penny:\n> On Tue, Dec 11, 2018 at 7:39 AM Johannes Schindelin wrote:\n>>> - pc-windows\n>>> - pc-win\n>>> - win\n>>\n>> I find all of those horrible.\n> \n> one windows triplet in use is \"x86_64-pc-windows\", used by Rust:\n> \n> https://forge.rust-lang.org/other-installation-methods.html\n> \n> which is how i came about my suggestions - again they arent great but they arent\n> misleading as \"Win32\" is.\n\nAs long as C:\\Windows\\System32 on my Windows computer contains only \n64-Bit binaries, I consider the characters \"3\" and \"2\" next to each \nother in this order just noise and without any form of information. The \nimportant part of the name is \"win\".\n\n-- Hannes\n"},{"id":"365169","messageId":"CAAXzdLU0Desw=kt2A3qHx8v=8hvKcN9OdV9fnXEcYiO=ht-t9A@mail.gmail.com","threadId":"49846","inReplyTo":"be24f331-5c8f-954d-e6f5-d5b09ee4e5f3@kdbg.org","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2018-12-12T12:40:23Z","receivedAt":"2018-12-12T12:40:29Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Wed, Dec 12, 2018 at 1:29 AM Johannes Sixt wrote:\n> As long as C:\\Windows\\System32 on my Windows computer contains only\n> 64-Bit binaries, I consider the characters \"3\" and \"2\" next to each\n> other in this order just noise and without any form of information. The\n> important part of the name is \"win\".\n\nsorry friend, but thats a logical fallacy :(\n\nhttp://yourlogicalfallacyis.com/no-true-scotsman\n\njust because the name \"System32\" is still in use (wrongly, I might add) doesnt\nmean that \"Win32\" should still be in use.\n\nEach name is a separate argument. The \"Win32\" name has been changed by Microsoft\nand shouldnt be used by Git if possible. Its an easy change and I could send\na pull request myself. However just because Microsoft hasnt changed \"Sytem32\"\ndoesnt mean that they wont or shouldnt - as you said its just as misleading. We\nshould fix ambiguities where we can, not embrace them.\n"},{"id":"365172","messageId":"nycvar.QRO.7.76.6.1812121432540.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"be24f331-5c8f-954d-e6f5-d5b09ee4e5f3@kdbg.org","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-12T13:33:47Z","receivedAt":"2018-12-12T13:34:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Hannes,\n\nOn Wed, 12 Dec 2018, Johannes Sixt wrote:\n\n> Am 12.12.18 um 01:42 schrieb Steven Penny:\n> > On Tue, Dec 11, 2018 at 7:39 AM Johannes Schindelin wrote:\n> > > > - pc-windows\n> > > > - pc-win\n> > > > - win\n> > >\n> > > I find all of those horrible.\n> > \n> > one windows triplet in use is \"x86_64-pc-windows\", used by Rust:\n> > \n> > https://forge.rust-lang.org/other-installation-methods.html\n> > \n> > which is how i came about my suggestions - again they arent great but they\n> > arent\n> > misleading as \"Win32\" is.\n> \n> As long as C:\\Windows\\System32 on my Windows computer contains only 64-Bit\n> binaries, I consider the characters \"3\" and \"2\" next to each other in this\n> order just noise and without any form of information. The important part of\n> the name is \"win\".\n\nFWIW I agree with you.\n\nThanks,\nDscho\n"},{"id":"365175","messageId":"nycvar.QRO.7.76.6.1812121435570.43@tvgsbejvaqbjf.bet","threadId":"49846","inReplyTo":"CABPp-BHqJ_Dqpi-N-GVu9difvh-SnD1SZ2-SqaG0ctu5fBX-Tw@mail.gmail.com","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-12T13:57:09Z","receivedAt":"2018-12-12T13:57:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Elijah,\n\nOn Tue, 11 Dec 2018, Elijah Newren wrote:\n\n> I'm worried based on other emails in this thread that there is a\n> fundamental difference in frame of reference leading to a\n> misunderstanding about rationale for naming, and worse that folks might\n> not even realize where the misunderstanding is coming from, attributing\n> it to different motives rather than different frames of reference.  If\n> that's true, I hope this email can begin the process of clearing up the\n> differences of understanding.  If I'm wrong, then I apologize for the\n> noise; just ignore me.\n\nI think you brought up quite a few good points (also in the part that I\ndid not quote).\n\nThe part I quoted brings up one particular aspect that I would like to\ndrive home a little more: the purpose of naming, and the historical\nreality. (\"hysterical raisins\" comes to mind.)\n\nIn Git, we have an awful lot of references to MINGW, which is the name of\na project that tried to allow compiling software targeting pure Windows\n(i.e. the Win32 API, without any POSIX compatibility layer) with the GNU C\ncompiler.\n\nAs many open source projects require more than just the GNU C compiler\n(e.g. a Bash to run ./configure), there is also MSys, which is a minimal\nfork of a then-current version of Cygwin, originally intended for the sole\npurpose to support building MINGW software.\n\nTo make things more confusing, at some stage the mingw-w64 project was\nstarted (not as a fork of MINGW, AFAIU), to address the notable lack of\n64-bit support in MINGW, and later the MSYS2 project was started, based on\nmingw-w64, to address the same issue with MSys (also not forking, but\ninstead starting from scratch).\n\nBack in 2006, when I started to port Git to Windows, I made use of MINGW\nand MSys (and I abused MSys by shipping their Bash with Git, which was\ndistinctly not intended a usage of their Bash). Hannes Sixt picked up when\nI stopped having access to a fast Windows machine, and kept my naming:\ncompat/mingw.c.\n\nNow, Philip Oakley, Jeff Hostetler and a few other developers spent quite\na bit of effort to make Git compile also with Visual C, and of course the\nreused parts of compat/mingw.c (whose name now does not make too much\nsense anymore, except in historical context).\n\nLikewise, when I switched to MSYS2/mingw-w64 with the major version jump\nto Git for Windows 2.x in 2015, I no longer use MINGW to compile\n*anything*.\n\nI hope that this illustrated a little bit how our names came about.\n\nOf course, we could now spend some time to change the names to reflect\nmore the product and brand names involved. There does not seem to be any\nreally compelling reason to do so, though. And I'd rather spend my time\ndeveloping exciting features. But that's my preference for my time, so if\nanybody comes along, making a strong case for renaming, in a well-crafted\npatch series, who am I to say no to that.\n\nCiao,\nDscho\n"},{"id":"365223","messageId":"xmqqsgz2f5hs.fsf@gitster-ct.c.googlers.com","threadId":"49846","inReplyTo":"CAAXzdLU0Desw=kt2A3qHx8v=8hvKcN9OdV9fnXEcYiO=ht-t9A@mail.gmail.com","subject":"Re: [PATCH v2 1/3] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-13T03:52:15Z","receivedAt":"2018-12-13T03:52:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> On Wed, Dec 12, 2018 at 1:29 AM Johannes Sixt wrote:\n>> As long as C:\\Windows\\System32 on my Windows computer contains only\n>> 64-Bit binaries, I consider the characters \"3\" and \"2\" next to each\n>> other in this order just noise and without any form of information. The\n>> important part of the name is \"win\".\n>\n> sorry friend, but thats a logical fallacy :(\n>\n> http://yourlogicalfallacyis.com/no-true-scotsman\n>\n> just because the name \"System32\" is still in use (wrongly, I might add) doesnt\n> mean that \"Win32\" should still be in use.\n>\n> Each name is a separate argument. The \"Win32\" name has been changed by Microsoft\n> and shouldnt be used by Git if possible. Its an easy change and I could send\n> a pull request myself. However just because Microsoft hasnt changed \"Sytem32\"\n> doesnt mean that they wont or shouldnt - as you said its just as misleading. We\n> should fix ambiguities where we can, not embrace them.\n\nFWIW, in the context of the Git development ecosystem, whatever\nDscho wants to do in compat/ that is limited to Windows is\n\"officially endorsed by Microsoft\" enough.\n\nAlso I do not think J6t felt 32 in System32 or in win32 was\nmisleading.  At least I didn't read the above that way.  \n"},{"id":"365423","messageId":"20181215043330.20162-1-tboegi@web.de","threadId":"49846","inReplyTo":"5bf18396.1c69fb81.20780.2b1d@mx.google.com","subject":"[PATCH v4 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"","fromEmail":"tboegi@web.de","sentAt":"2018-12-15T04:33:30Z","receivedAt":"2018-12-15T04:33:40Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"From: Torsten Bögershausen <tboegi@web.de>\n\nA regression for cygwin users was introduced with commit 05b458c,\n \"real_path: resolve symlinks by hand\".\n\nIn the the commit message we read:\n  The current implementation of real_path uses chdir() in order to resolve\n    symlinks.  Unfortunately this isn't thread-safe as chdir() affects a\n      process as a whole...\n\nThe old (and non-thread-save) OS calls chdir()/pwd() had been\nreplaced by a string operation.\nThe cygwin layer \"knows\" that \"C:\\cygwin\" is an absolute path,\nbut the new string operation does not.\n\n\"git clone <url> C:\\cygwin\\home\\USER\\repo\" fails like this:\nfatal: Invalid path '/home/USER/repo/C:\\cygwin\\home\\USER\\repo'\n\nThe solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\nis_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\nin the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n\nExtract the needed code into compat/win32/path-utils.[ch] and use it\nfor cygwin as well.\n\nReported-by: Steven Penny <svnpenn@gmail.com>\nHelped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n\nChanges since v3:\n  Rename e.g. mingw_skip_dos_drive_prefix() into\n              win32_skip_dos_drive_prefix()\n       as suggested by Dscho, thanls for that.\n  Add a tweak in t5601 for cygwin.\n\nThe test suite passes now on cygwin.\nThe \"Git for Windows\" build was tested was tested on\nthe gfw/master, with this commit cherry-picked on top.\n\n\n---\n compat/cygwin.c           | 19 -------------------\n compat/cygwin.h           |  2 --\n compat/mingw.c            | 29 +----------------------------\n compat/mingw.h            | 20 --------------------\n compat/win32/path-utils.c | 28 ++++++++++++++++++++++++++++\n compat/win32/path-utils.h | 20 ++++++++++++++++++++\n config.mak.uname          |  3 ++-\n git-compat-util.h         |  3 ++-\n t/t5601-clone.sh          |  2 +-\n 9 files changed, 54 insertions(+), 72 deletions(-)\n delete mode 100644 compat/cygwin.c\n delete mode 100644 compat/cygwin.h\n create mode 100644 compat/win32/path-utils.c\n create mode 100644 compat/win32/path-utils.h\n\ndiff --git a/compat/cygwin.c b/compat/cygwin.c\ndeleted file mode 100644\nindex b9862d606d..0000000000\n--- a/compat/cygwin.c\n+++ /dev/null\n@@ -1,19 +0,0 @@\n-#include \"../git-compat-util.h\"\n-#include \"../cache.h\"\n-\n-int cygwin_offset_1st_component(const char *path)\n-{\n-\tconst char *pos = path;\n-\t/* unc paths */\n-\tif (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n-\t\t/* skip server name */\n-\t\tpos = strchr(pos + 2, '/');\n-\t\tif (!pos)\n-\t\t\treturn 0; /* Error: malformed unc path */\n-\n-\t\tdo {\n-\t\t\tpos++;\n-\t\t} while (*pos && pos[0] != '/');\n-\t}\n-\treturn pos + is_dir_sep(*pos) - path;\n-}\ndiff --git a/compat/cygwin.h b/compat/cygwin.h\ndeleted file mode 100644\nindex 8e52de4644..0000000000\n--- a/compat/cygwin.h\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-int cygwin_offset_1st_component(const char *path);\n-#define offset_1st_component cygwin_offset_1st_component\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 34b3880b29..b459e1a291 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -350,7 +350,7 @@ static inline int needs_hiding(const char *path)\n \t\treturn 0;\n \n \t/* We cannot use basename(), as it would remove trailing slashes */\n-\tmingw_skip_dos_drive_prefix((char **)&path);\n+\twin32_skip_dos_drive_prefix((char **)&path);\n \tif (!*path)\n \t\treturn 0;\n \n@@ -2275,33 +2275,6 @@ pid_t waitpid(pid_t pid, int *status, int options)\n \treturn -1;\n }\n \n-int mingw_skip_dos_drive_prefix(char **path)\n-{\n-\tint ret = has_dos_drive_prefix(*path);\n-\t*path += ret;\n-\treturn ret;\n-}\n-\n-int mingw_offset_1st_component(const char *path)\n-{\n-\tchar *pos = (char *)path;\n-\n-\t/* unc paths */\n-\tif (!skip_dos_drive_prefix(&pos) &&\n-\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n-\t\t/* skip server name */\n-\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n-\t\tif (!pos)\n-\t\t\treturn 0; /* Error: malformed unc path */\n-\n-\t\tdo {\n-\t\t\tpos++;\n-\t\t} while (*pos && !is_dir_sep(*pos));\n-\t}\n-\n-\treturn pos + is_dir_sep(*pos) - path;\n-}\n-\n int xutftowcsn(wchar_t *wcs, const char *utfs, size_t wcslen, int utflen)\n {\n \tint upos = 0, wpos = 0;\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 8c24ddaa3e..30d9fb3e36 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -443,32 +443,12 @@ HANDLE winansi_get_osfhandle(int fd);\n  * git specific compatibility\n  */\n \n-#define has_dos_drive_prefix(path) \\\n-\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n-int mingw_skip_dos_drive_prefix(char **path);\n-#define skip_dos_drive_prefix mingw_skip_dos_drive_prefix\n-static inline int mingw_is_dir_sep(int c)\n-{\n-\treturn c == '/' || c == '\\\\';\n-}\n-#define is_dir_sep mingw_is_dir_sep\n-static inline char *mingw_find_last_dir_sep(const char *path)\n-{\n-\tchar *ret = NULL;\n-\tfor (; *path; ++path)\n-\t\tif (is_dir_sep(*path))\n-\t\t\tret = (char *)path;\n-\treturn ret;\n-}\n static inline void convert_slashes(char *path)\n {\n \tfor (; *path; path++)\n \t\tif (*path == '\\\\')\n \t\t\t*path = '/';\n }\n-#define find_last_dir_sep mingw_find_last_dir_sep\n-int mingw_offset_1st_component(const char *path);\n-#define offset_1st_component mingw_offset_1st_component\n #define PATH_SEP ';'\n extern char *mingw_query_user_email(void);\n #define query_user_email mingw_query_user_email\ndiff --git a/compat/win32/path-utils.c b/compat/win32/path-utils.c\nnew file mode 100644\nindex 0000000000..d9d3641de8\n--- /dev/null\n+++ b/compat/win32/path-utils.c\n@@ -0,0 +1,28 @@\n+#include \"../../git-compat-util.h\"\n+\n+int win32_skip_dos_drive_prefix(char **path)\n+{\n+\tint ret = has_dos_drive_prefix(*path);\n+\t*path += ret;\n+\treturn ret;\n+}\n+\n+int win32_offset_1st_component(const char *path)\n+{\n+\tchar *pos = (char *)path;\n+\n+\t/* unc paths */\n+\tif (!skip_dos_drive_prefix(&pos) &&\n+\t\t\tis_dir_sep(pos[0]) && is_dir_sep(pos[1])) {\n+\t\t/* skip server name */\n+\t\tpos = strpbrk(pos + 2, \"\\\\/\");\n+\t\tif (!pos)\n+\t\t\treturn 0; /* Error: malformed unc path */\n+\n+\t\tdo {\n+\t\t\tpos++;\n+\t\t} while (*pos && !is_dir_sep(*pos));\n+\t}\n+\n+\treturn pos + is_dir_sep(*pos) - path;\n+}\ndiff --git a/compat/win32/path-utils.h b/compat/win32/path-utils.h\nnew file mode 100644\nindex 0000000000..0f70d43920\n--- /dev/null\n+++ b/compat/win32/path-utils.h\n@@ -0,0 +1,20 @@\n+#define has_dos_drive_prefix(path) \\\n+\t(isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)\n+int win32_skip_dos_drive_prefix(char **path);\n+#define skip_dos_drive_prefix win32_skip_dos_drive_prefix\n+static inline int win32_is_dir_sep(int c)\n+{\n+\treturn c == '/' || c == '\\\\';\n+}\n+#define is_dir_sep win32_is_dir_sep\n+static inline char *win32_find_last_dir_sep(const char *path)\n+{\n+\tchar *ret = NULL;\n+\tfor (; *path; ++path)\n+\t\tif (is_dir_sep(*path))\n+\t\t\tret = (char *)path;\n+\treturn ret;\n+}\n+#define find_last_dir_sep win32_find_last_dir_sep\n+int win32_offset_1st_component(const char *path);\n+#define offset_1st_component win32_offset_1st_component\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 3ee7da0e23..60876e26f4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -187,7 +187,7 @@ ifeq ($(uname_O),Cygwin)\n \tUNRELIABLE_FSTAT = UnfortunatelyYes\n \tOBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo\n \tMMAP_PREVENTS_DELETE = UnfortunatelyYes\n-\tCOMPAT_OBJS += compat/cygwin.o\n+\tCOMPAT_OBJS += compat/win32/path-utils.o\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n endif\n ifeq ($(uname_S),FreeBSD)\n@@ -527,6 +527,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tCOMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\n+\t\tcompat/win32/path-utils.o \\\n \t\tcompat/win32/pthread.o compat/win32/syslog.o \\\n \t\tcompat/win32/dirent.o\n \tBASIC_CFLAGS += -DWIN32 -DPROTECT_NTFS_DEFAULT=1\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 09b0102cae..5702556c89 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -193,10 +193,11 @@\n #endif\n \n #if defined(__CYGWIN__)\n-#include \"compat/cygwin.h\"\n+#include \"compat/win32/path-utils.h\"\n #endif\n #if defined(__MINGW32__)\n /* pull in Windows compatibility stuff */\n+#include \"compat/win32/path-utils.h\"\n #include \"compat/mingw.h\"\n #elif defined(_MSC_VER)\n #include \"compat/msvc.h\"\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex 8bbc7068ac..d6948cbdab 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -487,7 +487,7 @@ test_clone_url () {\n \texpect_ssh \"$@\"\n }\n \n-test_expect_success !MINGW 'clone c:temp is ssl' '\n+test_expect_success !MINGW,!CYGWIN 'clone c:temp is ssl' '\n \ttest_clone_url c:temp c temp\n '\n \n-- \n2.20.0\n\n"},{"id":"374804","messageId":"87sgtxi9ed.fsf@Rainer.invalid","threadId":"49846","inReplyTo":"20181215043330.20162-1-tboegi@web.de","subject":"Re: [PATCH v4 1/1] git clone <url> C:\\cygwin\\home\\USER\\repo' is working (again)","fromName":"Achim Gratz","fromEmail":"stromeko@nexgo.de","sentAt":"2019-05-02T07:48:58Z","receivedAt":"2019-05-02T07:49:11Z","isPatch":true,"sender":{"key":"stromeko@nexgo.de","avatar":null},"body":"[Trying to revive that discussion]\n\ntboegi@web.de writes:\n> The cygwin layer \"knows\" that \"C:\\cygwin\" is an absolute path,\n> but the new string operation does not.\n\nThen use the Cygwin API to produce the corresponding POSIX path and use\nthat.  Also, why does Git not use POSIX realpath on systems where it's\navailable?\n\n> \"git clone <url> C:\\cygwin\\home\\USER\\repo\" fails like this:\n> fatal: Invalid path '/home/USER/repo/C:\\cygwin\\home\\USER\\repo'\n>\n> The solution is to implement has_dos_drive_prefix(), skip_dos_drive_prefix()\n> is_dir_sep(), offset_1st_component() and convert_slashes() for cygwin\n> in the same way as it is done in 'Git for Windows' in compat/mingw.[ch]\n\nNo.  I don't care what MinGW does, but keep these heuristics out of Cygwin.\n\n> Extract the needed code into compat/win32/path-utils.[ch] and use it\n> for cygwin as well.\n\nCan you please remove that Win32 stuff from Cygwin again?\n\n\nRegards,\nAchim.\n-- \n+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+\n\nDIY Stuff:\nhttp://Synth.Stromeko.net/DIY.html\n\n"}]}