{"thread":{"id":"21990","subject":"[PATCH] rebase -i: abort cleanly if the editor fails to launch","startedAt":"2009-12-19T12:04:03Z","lastAt":"2009-12-20T07:31:20Z","messageCount":5,"participants":["Björn Gustavsson","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"130135","messageId":"4B2CC133.9010704@gmail.com","threadId":"21990","inReplyTo":null,"subject":"[PATCH] rebase -i: abort cleanly if the editor fails to launch","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2009-12-19T12:04:03Z","receivedAt":"2009-12-19T12:04:03Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"If the user's configured editor is emacsclient, the editor\nwill fail to launch if emacs is not running and the git\ncommand that tried to lanuch the editor will abort. For most\ncommands, all you have to do is to start emacs and repeat\nthe command.\n\nThe \"git rebase -i\" command, however, aborts without cleaning\nthe \"$GIT_DIR/rebase-merge\" directory if it fails to launch the\neditor, so you'll need to do \"git rebase --abort\" before\nrepeating the rebase command.\n\nChange \"git rebase -i\" to terminate using \"die_abort\" (instead of\nwith \"die\") if the initial launch of the editor fails.\n\nSigned-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n---\n git-rebase--interactive.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0bd3bf7..d529328 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -779,7 +779,7 @@ EOF\n \n \t\tcp \"$TODO\" \"$TODO\".backup\n \t\tgit_editor \"$TODO\" ||\n-\t\t\tdie \"Could not execute editor\"\n+\t\t\tdie_abort \"Could not execute editor\"\n \n \t\thas_action \"$TODO\" ||\n \t\t\tdie_abort \"Nothing to do\"\n-- \n1.6.6.rc3.dirty\n"},{"id":"130159","messageId":"7v8wcy7kyc.fsf@alter.siamese.dyndns.org","threadId":"21990","inReplyTo":"4B2CC133.9010704@gmail.com","subject":"Re: [PATCH] rebase -i: abort cleanly if the editor fails to launch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-19T20:44:27Z","receivedAt":"2009-12-19T20:44:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Björn Gustavsson <bgustavsson@gmail.com> writes:\n\n> If the user's configured editor is emacsclient, the editor\n> will fail to launch if emacs is not running and the git\n> command that tried to lanuch the editor will abort. For most\n> commands, all you have to do is to start emacs and repeat\n> the command.\n>\n> The \"git rebase -i\" command, however, aborts without cleaning\n> the \"$GIT_DIR/rebase-merge\" directory if it fails to launch the\n> editor, so you'll need to do \"git rebase --abort\" before\n> repeating the rebase command.\n>\n> Change \"git rebase -i\" to terminate using \"die_abort\" (instead of\n> with \"die\") if the initial launch of the editor fails.\n>\n> Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n\nTwo questions:\n\n - Is emacsclient the _only_ editor that can exit with non-zero status to\n   signal an error condition \"the user invoked me to edit an existing\n   file, but I ended up not letting the user edit it\"?\n\n - Are there editors that let you exit with non-zero status on demand?\n\nThe above is not a complaint to your log message, but is a genuine request\nfor information.\n\nAn editor that can exit with non-zero status on demand could use this\ncodepath to abort the rebase, when a user realizes that the edit s/he has\ndone so far was completely bogus [*1*].  In such a case, the existing\nerror message \"Could not execute editor\" may sound funny.\n\nRegardless of that small issue, I think the patch to clean-up makes sense.\n\nThanks.\n\n\n[Footnote]\n\n*1* We interpret a completely empty $TODO as a signal from the user to\nabort the sequencer (the literal interpretation of such a $TODO would be\nto not pick any commits, which could be a source of potential confusion),\nso it is not an issue in practice if your editor does not allow you to\nexit with non-zero status to signal an exception.  You can remove all\nlines and exit the editor normally instead.\n"},{"id":"130161","messageId":"alpine.DEB.1.00.0912192156030.4985@pacific.mpi-cbg.de","threadId":"21990","inReplyTo":"7v8wcy7kyc.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] rebase -i: abort cleanly if the editor fails to launch","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-12-19T20:57:16Z","receivedAt":"2009-12-19T20:57:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 19 Dec 2009, Junio C Hamano wrote:\n\n> Björn Gustavsson <bgustavsson@gmail.com> writes:\n> \n> > If the user's configured editor is emacsclient, the editor\n> > will fail to launch if emacs is not running and the git\n> > command that tried to lanuch the editor will abort. For most\n> > commands, all you have to do is to start emacs and repeat\n> > the command.\n> >\n> > The \"git rebase -i\" command, however, aborts without cleaning\n> > the \"$GIT_DIR/rebase-merge\" directory if it fails to launch the\n> > editor, so you'll need to do \"git rebase --abort\" before\n> > repeating the rebase command.\n> >\n> > Change \"git rebase -i\" to terminate using \"die_abort\" (instead of\n> > with \"die\") if the initial launch of the editor fails.\n> >\n> > Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n> \n> Two questions:\n> \n>  - Is emacsclient the _only_ editor that can exit with non-zero status to\n>    signal an error condition \"the user invoked me to edit an existing\n>    file, but I ended up not letting the user edit it\"?\n\nThe non-existent editor also aborts with a non-zero status.\n\n> An editor that can exit with non-zero status on demand could use this\n> codepath to abort the rebase,\n\nRemoving all lines of the edit script will abort an interactive rebase.\n\nCiao,\nDscho\n"},{"id":"130181","messageId":"7vmy1ecdlx.fsf@alter.siamese.dyndns.org","threadId":"21990","inReplyTo":"alpine.DEB.1.00.0912192156030.4985@pacific.mpi-cbg.de","subject":"Re: [PATCH] rebase -i: abort cleanly if the editor fails to launch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-20T07:24:10Z","receivedAt":"2009-12-20T07:24:10Z","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> The non-existent editor also aborts with a non-zero status.\n\nThanks; that is a good point.  Perhaps we might want to say what editor we\ntried to run in the error message.\n\n>> An editor that can exit with non-zero status on demand could use this\n>> codepath to abort the rebase,\n>\n> Removing all lines of the edit script will abort an interactive rebase.\n\nI guess you replied too fast without reading the message to the end ;-)\n"},{"id":"130182","messageId":"6672d0160912192331i7aa770d4ta38207d756d204ff@mail.gmail.com","threadId":"21990","inReplyTo":"7v8wcy7kyc.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] rebase -i: abort cleanly if the editor fails to launch","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2009-12-20T07:31:20Z","receivedAt":"2009-12-20T07:31:20Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"2009/12/19 Junio C Hamano <gitster@pobox.com>:\n\n> Two questions:\n>\n>  - Is emacsclient the _only_ editor that can exit with non-zero status to\n>   signal an error condition \"the user invoked me to edit an existing\n>   file, but I ended up not letting the user edit it\"?\n\nI have no idea, but my guess is that it would only happen in\nexceptional circumstances (e.g. a file system that has run out\nof space).\n\n>  - Are there editors that let you exit with non-zero status on demand?\n>\n> The above is not a complaint to your log message, but is a genuine request\n> for information.\n>\n> An editor that can exit with non-zero status on demand could use this\n> codepath to abort the rebase, when a user realizes that the edit s/he has\n> done so far was completely bogus [*1*].  In such a case, the existing\n> error message \"Could not execute editor\" may sound funny.\n\nAgain, no idea, but I have never heard of such a feature. I think\nthat anyone advanced enough to use such a feature in an editor\nwould not be troubled by \"Could not execute editor\".\n\n\nI mentioned emacsclient because it is a real annoyance\nthat has bitten me more than once (usually because I have\nclosed my local emacs while working on a remote computer\nbecause I prefer to only keep windows that I am actively\nworking with), but my patch will help if the user has configured\na non-existent editor too (but such a problem usually\nonly happens once).\n\n-- \nBjörn Gustavsson, Erlang/OTP, Ericsson AB\n"}]}