{"thread":{"id":"55114","subject":"default editor","startedAt":"2021-02-07T13:25:41Z","lastAt":"2021-02-12T06:04:21Z","messageCount":9,"participants":["M Douglas McIlroy","brian m. carlson","Junio C Hamano","Jeff King","Eric Sunshine","Adam Dinwoodie"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"416352","messageId":"CAKH6PiWS5DvqctFnvZ+uyOzBs75hcy9HzbW_3gUCu+RE+oOYyw@mail.gmail.com","threadId":"55114","inReplyTo":null,"subject":"default editor","fromName":"M Douglas McIlroy","fromEmail":"m.douglas.mcilroy@dartmouth.edu","sentAt":"2021-02-07T13:24:07Z","receivedAt":"2021-02-07T13:25:41Z","isPatch":false,"sender":{"key":"m.douglas.mcilroy@dartmouth.edu","avatar":null},"body":"While downloading git, I was asked to name a default editor, which I\ndid: ed. from cygwin. It worked in the enuing test, but was rejected\nbecause it returned an error. I suppose this is because\ncygwin return  conventions are those of Unix, not Windows. That raises\nthe question: does it matter? Does any other part of git depend on the\neditor's return value?\n"},{"id":"416356","messageId":"YCAk8Zx8KvZhaJMx@camp.crustytoothpaste.net","threadId":"55114","inReplyTo":"CAKH6PiWS5DvqctFnvZ+uyOzBs75hcy9HzbW_3gUCu+RE+oOYyw@mail.gmail.com","subject":"Re: default editor","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-02-07T17:35:45Z","receivedAt":"2021-02-07T17:37:25Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-02-07 at 13:24:07, M Douglas McIlroy wrote:\n> While downloading git, I was asked to name a default editor, which I\n> did: ed. from cygwin. It worked in the enuing test, but was rejected\n> because it returned an error. I suppose this is because\n> cygwin return  conventions are those of Unix, not Windows. That raises\n> the question: does it matter? Does any other part of git depend on the\n> editor's return value?\n\nFirst of all, I don't use Windows and this sounds like a\nWindows-specific problem, so you may have more help at the Git for\nWindows issue tracker.  But I'll try to help anyway.\n\nAt the command line, what does \"git var GIT_EDITOR\" print?  Is it\n\"/usr/bin/ed\" or the like?  Or is it something like \"/c/...\"?  Also,\nwhat is the exact error message you receive from trying to run your\ncommand (copy and paste)?\n\nThe reason I ask is that Git for Windows ships with a POSIX-like\nenvironment called MSYS, and as such, Unix-style paths are interpreted\naccording to that.  So to specify a path for Cygwin, you'd need to\nspecify it as a Unix-style path under /c (or /d, or whatever drive) so\nthat it could be invoked as a normal Windows program and not something\nrelative to the MSYS environment.  However, the path is handed off to\nthe shell, so it needs to be in a form that uses slashes.\n\nI don't think the return value is the problem.  Both Unix and Windows\nreturn 0 on success and nonzero on error, and Git will interpret\neditor return codes that way.\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"416357","messageId":"xmqqlfbz927i.fsf@gitster.c.googlers.com","threadId":"55114","inReplyTo":"YCAk8Zx8KvZhaJMx@camp.crustytoothpaste.net","subject":"Re: default editor","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-07T18:12:33Z","receivedAt":"2021-02-07T18:13:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> First of all, I don't use Windows and this sounds like a\n> Windows-specific problem, so you may have more help at the Git for\n> Windows issue tracker.  But I'll try to help anyway.\n\nI don't do Windows, either ;-)\n\n> I don't think the return value is the problem.  Both Unix and Windows\n> return 0 on success and nonzero on error, and Git will interpret\n> editor return codes that way.\n\nWhen git spawns an editor, it is asking the editor to give the text\nfile that has been edited by the end user into a shape that the end\nuser is happy with.  A non-zero exit is a way for the end user to\ntell the editor (and hence git) that, even though the user has ended\nthe editor session, the resulting contents is not satisfactory and\nnot to be used.\n\nIf the 'ed' in question behaves the same as traditional UNIX 'ed' (I\nam guessing so, as even this is on Windows, Cygwin was mentioned),\nyou can start making changes and attempt to quit without saving by\ntyping 'q<RET>' twice (the first one will be greeted with '?'\nmeaning \"are you sure you want to quit without saving\", and the\nsecond one lets you quit).  'ed' will signal the calling environment\nthat the editor session was aborted by exiting with a non-zero\nstatus.\n\n"},{"id":"416368","messageId":"YCAzcs1e08Qnk2wa@coredump.intra.peff.net","threadId":"55114","inReplyTo":"xmqqlfbz927i.fsf@gitster.c.googlers.com","subject":"Re: default editor","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-07T18:37:38Z","receivedAt":"2021-02-07T18:38:21Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Feb 07, 2021 at 10:12:33AM -0800, Junio C Hamano wrote:\n\n> > I don't think the return value is the problem.  Both Unix and Windows\n> > return 0 on success and nonzero on error, and Git will interpret\n> > editor return codes that way.\n> \n> When git spawns an editor, it is asking the editor to give the text\n> file that has been edited by the end user into a shape that the end\n> user is happy with.  A non-zero exit is a way for the end user to\n> tell the editor (and hence git) that, even though the user has ended\n> the editor session, the resulting contents is not satisfactory and\n> not to be used.\n> \n> If the 'ed' in question behaves the same as traditional UNIX 'ed' (I\n> am guessing so, as even this is on Windows, Cygwin was mentioned),\n> you can start making changes and attempt to quit without saving by\n> typing 'q<RET>' twice (the first one will be greeted with '?'\n> meaning \"are you sure you want to quit without saving\", and the\n> second one lets you quit).  'ed' will signal the calling environment\n> that the editor session was aborted by exiting with a non-zero\n> status.\n\nThere are lots of ways to make ed exit non-zero. Any invalid command\nduring the session will do. E.g.:\n\n       $ echo bar >foo\n       $ ed foo\n ed -> 4\n me -> l\n ed -> bar$\n me -> 2l\n ed -> ?\n me -> q\n       $ echo $?\n       1\n\nThe \"2l\" was bogus (there is no line 2). It seems likely that an\ninteractive user might make at least one invalid command while editing.\nSome versions (like GNU ed) have a \"-l\" option to loosen the exit code.\n\n-Peff\n"},{"id":"416375","messageId":"YCA64/coa/J5mBCl@camp.crustytoothpaste.net","threadId":"55114","inReplyTo":"YCAzcs1e08Qnk2wa@coredump.intra.peff.net","subject":"Re: default editor","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-02-07T19:09:23Z","receivedAt":"2021-02-07T19:10:41Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-02-07 at 18:37:38, Jeff King wrote:\n> There are lots of ways to make ed exit non-zero. Any invalid command\n> during the session will do. E.g.:\n> \n>        $ echo bar >foo\n>        $ ed foo\n>  ed -> 4\n>  me -> l\n>  ed -> bar$\n>  me -> 2l\n>  ed -> ?\n>  me -> q\n>        $ echo $?\n>        1\n> \n> The \"2l\" was bogus (there is no line 2). It seems likely that an\n> interactive user might make at least one invalid command while editing.\n> Some versions (like GNU ed) have a \"-l\" option to loosen the exit code.\n\nI wasn't previously aware of this behavior, and it's not very helpful\nunless you're scripting, since humans inevitably make mistakes.  ex\nseems to have a more forgiving behavior; maybe it's similar enough that\nit'd be a better choice?\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"416386","messageId":"CAPig+cQ=nR7O+uNAufB7ohKN2ZoUP6n1aLbZBz2jeFKMFbaAcA@mail.gmail.com","threadId":"55114","inReplyTo":"YCAzcs1e08Qnk2wa@coredump.intra.peff.net","subject":"Re: default editor","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-02-07T21:57:07Z","receivedAt":"2021-02-07T21:58:24Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Feb 7, 2021 at 1:38 PM Jeff King <peff@peff.net> wrote:\n> The \"2l\" was bogus (there is no line 2). It seems likely that an\n> interactive user might make at least one invalid command while editing.\n> Some versions (like GNU ed) have a \"-l\" option to loosen the exit code.\n\nCygwin `ed` does support `-l`, so that's helpful, although it still\nfails the \"test editor\" button in the Git-For-Windows installer\nprogram since the installer calls `ed` with a Windows style path\nrather than a Unix style path which Cygwin `ed` doesn't understand. It\nis possible to skip \"test editor\" and continue Git-For-Windows\ninstallation without testing. The bigger problem after that, at least\nin my testing, is that when `git` from Git-For-Windows itself\neventually launches Cygwin `ed` at commit time, it bombs with:\n\n    0 [main] ed (2444) C:\\cygwin64\\bin\\ed.exe: *** fatal error -\n    cygheap base mismatch detected - 0x18034C408/0x180347408.\n\nIn fact, Cygwin `ed` crashes with that same problem even just being\nlaunched from the MSYS shell provided by Git-For-Windows due to bad\ninteraction between the DLL's. On the other hand, Cygwin `ed` launches\njust fine from the Cygwin shell as one would expect.\n\nBy the way, it's also possible to install Cygwin's Git from the Cygwin\ninstaller rather than attempting to use the Git provided by the\nGit-For-Windows project. The combination of Cygwin `ed` and Cygwin\n`git` works just fine (in my tests) once you configure `ed` as the Git\neditor either by setting GIT_EDITOR or EDITOR environment variables to\n`ed -l` or by configuring git itself:\n\n    git config --global --add core.config 'ed -l'\n\n(You would want to uninstall Git-For-Windows, too, if you have it installed.)\n"},{"id":"416404","messageId":"CA+kUOakk_=DRzroNb+0_RcfbkaOYLJxY=AtYMe4YQwuhB+_P_w@mail.gmail.com","threadId":"55114","inReplyTo":"CAPig+cQ=nR7O+uNAufB7ohKN2ZoUP6n1aLbZBz2jeFKMFbaAcA@mail.gmail.com","subject":"Re: default editor","fromName":"Adam Dinwoodie","fromEmail":"adam@dinwoodie.org","sentAt":"2021-02-08T10:03:15Z","receivedAt":"2021-02-08T10:14:05Z","isPatch":false,"sender":{"key":"adam@dinwoodie.org","avatar":"https://avatars.githubusercontent.com/u/1397507?v=4"},"body":"On Sun, 7 Feb 2021 at 21:59, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> By the way, it's also possible to install Cygwin's Git from the Cygwin\n> installer rather than attempting to use the Git provided by the\n> Git-For-Windows project. The combination of Cygwin `ed` and Cygwin\n> `git` works just fine (in my tests) once you configure `ed` as the Git\n> editor either by setting GIT_EDITOR or EDITOR environment variables to\n> `ed -l` or by configuring git itself:\n>\n>     git config --global --add core.config 'ed -l'\n>\n> (You would want to uninstall Git-For-Windows, too, if you have it installed.)\n\nAs the Cygwin Git maintainer, I'd strongly recommend this approach:\neither use a Cygwin toolchain or a Git for Windows one, rather than\ntrying to combine the two. While Cygwin and the Git for Windows\nenvironment share common ancestry, they have substantial differences\narising from the fact that Cygwin generally attempts to provide an\nenvironment that's as close to Unix-like as possible, while Git for\nWindows is aiming for compatibility with native Windows applications.\nDifferences in handling paths and return codes are to be expected.\n\nI expect it is possible to use a Cygwin editor with Git for Windows,\nbut I don't think it's an expected use case, and I'm not aware of\nanyone else having produced and published documentation of the\nconfiguration and wrapper scripts I imagine you would need to convert\nbetween the two interfaces.\n\nAdam\n"},{"id":"416745","messageId":"CAKH6PiXj39+8SQLiJfdDWyg=vmqiNAba=DKffg3adfztWJ0w_Q@mail.gmail.com","threadId":"55114","inReplyTo":"CA+kUOakk_=DRzroNb+0_RcfbkaOYLJxY=AtYMe4YQwuhB+_P_w@mail.gmail.com","subject":"Re: default editor","fromName":"M Douglas McIlroy","fromEmail":"m.douglas.mcilroy@dartmouth.edu","sentAt":"2021-02-11T15:15:09Z","receivedAt":"2021-02-11T15:22:58Z","isPatch":false,"sender":{"key":"m.douglas.mcilroy@dartmouth.edu","avatar":null},"body":"Eric and Adam,\n\nMany thanks for so thoroughly exploring my query. I have long lived\nwith the limitations of\ninvoking Windows apps from Cygwin. Fortuitously I could work around\nthem without resorting\nto \"command prompt\", though clearly that isn't always possible. And\nyou have shed light\non the difficulty of the opposite: invoking Cygwin apps from Windows.\n\nDoug\n\nOn Mon, Feb 8, 2021 at 5:03 AM Adam Dinwoodie <adam@dinwoodie.org> wrote:\n>\n> On Sun, 7 Feb 2021 at 21:59, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> > By the way, it's also possible to install Cygwin's Git from the Cygwin\n> > installer rather than attempting to use the Git provided by the\n> > Git-For-Windows project. The combination of Cygwin `ed` and Cygwin\n> > `git` works just fine (in my tests) once you configure `ed` as the Git\n> > editor either by setting GIT_EDITOR or EDITOR environment variables to\n> > `ed -l` or by configuring git itself:\n> >\n> >     git config --global --add core.config 'ed -l'\n> >\n> > (You would want to uninstall Git-For-Windows, too, if you have it installed.)\n>\n> As the Cygwin Git maintainer, I'd strongly recommend this approach:\n> either use a Cygwin toolchain or a Git for Windows one, rather than\n> trying to combine the two. While Cygwin and the Git for Windows\n> environment share common ancestry, they have substantial differences\n> arising from the fact that Cygwin generally attempts to provide an\n> environment that's as close to Unix-like as possible, while Git for\n> Windows is aiming for compatibility with native Windows applications.\n> Differences in handling paths and return codes are to be expected.\n>\n> I expect it is possible to use a Cygwin editor with Git for Windows,\n> but I don't think it's an expected use case, and I'm not aware of\n> anyone else having produced and published documentation of the\n> configuration and wrapper scripts I imagine you would need to convert\n> between the two interfaces.\n>\n> Adam\n"},{"id":"416783","messageId":"CAPig+cQrYtzk+BZkSc90dj_QavWO1i6FVExF=JzggHGhhO7yzQ@mail.gmail.com","threadId":"55114","inReplyTo":"CAKH6PiXj39+8SQLiJfdDWyg=vmqiNAba=DKffg3adfztWJ0w_Q@mail.gmail.com","subject":"Re: default editor","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-02-12T06:03:08Z","receivedAt":"2021-02-12T06:04:21Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Feb 11, 2021 at 10:15 AM M Douglas McIlroy\n<m.douglas.mcilroy@dartmouth.edu> wrote:\n> Many thanks for so thoroughly exploring my query.\n\nYou are very welcome.\n\n> I have long lived with the limitations of invoking Windows apps from\n> Cygwin. Fortuitously I could work around them without resorting to\n> \"command prompt\", though clearly that isn't always possible. And you\n> have shed light on the difficulty of the opposite: invoking Cygwin\n> apps from Windows.\n\nWere you able to resolve the situation (for instance, by staying\nentirely within the Cygwin ecosystem for `git` and `ed`)?\n"}]}