{"thread":{"id":"31584","subject":"[PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction","startedAt":"2012-09-18T11:15:26Z","lastAt":"2012-09-18T20:29:20Z","messageCount":5,"participants":["Johannes Sixt","Matthieu Moy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"199357","messageId":"505857CE.3050909@viscovery.net","threadId":"31584","inReplyTo":null,"subject":"[PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-09-18T11:15:26Z","receivedAt":"2012-09-18T11:15:26Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nWhen the todo sheet of interactive rebase instructs to run a non-existing\ncommand, the operation stops with the following error:\n\n  Execution failed: no-such\n  You can fix the problem, and then run\n\n          git rebase --continue\n\n  fatal: 'rebase' appears to be a git command, but we were not\n  able to execute it. Maybe git-rebase is broken?\n\nThe reason is that the shell that attempted to run the command exits with\ncode 127. rebase--interactive just forwards this code to the caller (the\ngit wrapper). But our smart run-command infrastructure detects this\nspecial exit code and turns it into ENOENT, which in turn is interpreted\nby the git wrapper as if the external command that it just executed did\nnot exist. This is finally translated to the misleading last two lines in\nerror message cited above.\n\nFix it by translating the error code before it is forwarded.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n An alternative fix would be to just ignore the shell's status code.\n I decided that it is worth keeping it: better safe than sorry.\n\n BTW, the problem existed since day 1 of the 'exec' feature.\n\n git-rebase--interactive.sh    |  4 ++++\n t/t3404-rebase-interactive.sh | 11 +++++++++++\n 2 files changed, 15 insertions(+)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a09e842..56707d7 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -544,6 +544,10 @@ do_next () {\n \t\t\twarn\n \t\t\twarn \"\tgit rebase --continue\"\n \t\t\twarn\n+\t\t\tif test $status -eq 127\t\t# command not found\n+\t\t\tthen\n+\t\t\t\tstatus=1\n+\t\t\tfi\n \t\t\texit \"$status\"\n \t\telif test \"$dirty\" = t\n \t\tthen\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 7304b66..7a71760 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -118,6 +118,17 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '\n \tgit rebase --continue\n '\n \n+test_expect_success 'rebase -i with exec of inexistent command' '\n+\tgit checkout master &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\t(\n+\tFAKE_LINES=\"exec_this-command-does-not-exist 1\" &&\n+\texport FAKE_LINES &&\n+\ttest_must_fail git rebase -i HEAD^ >actual 2>&1\n+\t) &&\n+\t! grep \"Maybe git-rebase is broken\" actual\n+'\n+\n test_expect_success 'no changes are a nop' '\n \tgit checkout branch2 &&\n \tgit rebase -i F &&\n-- \n1.7.12.1720.gb55457a.dirty\n"},{"id":"199358","messageId":"vpq7grrlgqy.fsf@grenoble-inp.fr","threadId":"31584","inReplyTo":"505857CE.3050909@viscovery.net","subject":"Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-09-18T11:20:21Z","receivedAt":"2012-09-18T11:20:21Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> From: Johannes Sixt <j6t@kdbg.org>\n>\n> When the todo sheet of interactive rebase instructs to run a non-existing\n> command, the operation stops with the following error:\n>\n>   Execution failed: no-such\n>   You can fix the problem, and then run\n>\n>           git rebase --continue\n>\n>   fatal: 'rebase' appears to be a git command, but we were not\n>   able to execute it. Maybe git-rebase is broken?\n\nWhile you're there, maybe you want to turn the first line into\n\nExecution failed: no-such (command not found)\n\nIn any case, the patch sounds good, thanks.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"199361","messageId":"50585B1E.6030900@viscovery.net","threadId":"31584","inReplyTo":"vpq7grrlgqy.fsf@grenoble-inp.fr","subject":"Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-09-18T11:29:34Z","receivedAt":"2012-09-18T11:29:34Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 9/18/2012 13:20, schrieb Matthieu Moy:\n> Johannes Sixt <j.sixt@viscovery.net> writes:\n> \n>> From: Johannes Sixt <j6t@kdbg.org>\n>>\n>> When the todo sheet of interactive rebase instructs to run a non-existing\n>> command, the operation stops with the following error:\n>>\n>>   Execution failed: no-such\n>>   You can fix the problem, and then run\n>>\n>>           git rebase --continue\n>>\n>>   fatal: 'rebase' appears to be a git command, but we were not\n>>   able to execute it. Maybe git-rebase is broken?\n> \n> While you're there, maybe you want to turn the first line into\n> \n> Execution failed: no-such (command not found)\n\nNo, I don't want to: Neither do we have errno here, nor can we be specific\nenough because the whole shell script the user gave after 'exec' is\nrepeated here.\n\nI would rather remove the line so that it does not distract from the more\nspecific error message that the shell gave. On top of that, the command is\nalready dumped before it is executed; we don't need to repeat it.\n\n-- Hannes\n"},{"id":"199362","messageId":"vpqtxuvk1bx.fsf@grenoble-inp.fr","threadId":"31584","inReplyTo":"50585B1E.6030900@viscovery.net","subject":"Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-09-18T11:38:42Z","receivedAt":"2012-09-18T11:38:42Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Am 9/18/2012 13:20, schrieb Matthieu Moy:\n>> Johannes Sixt <j.sixt@viscovery.net> writes:\n>> \n>>> From: Johannes Sixt <j6t@kdbg.org>\n>>>\n>>> When the todo sheet of interactive rebase instructs to run a non-existing\n>>> command, the operation stops with the following error:\n>>>\n>>>   Execution failed: no-such\n>>>   You can fix the problem, and then run\n>>>\n>>>           git rebase --continue\n>>>\n>>>   fatal: 'rebase' appears to be a git command, but we were not\n>>>   able to execute it. Maybe git-rebase is broken?\n>> \n>> While you're there, maybe you want to turn the first line into\n>> \n>> Execution failed: no-such (command not found)\n>\n> No, I don't want to: Neither do we have errno here, nor can we be specific\n> enough because the whole shell script the user gave after 'exec' is\n> repeated here.\n>\n> I would rather remove the line so that it does not distract from the more\n> specific error message that the shell gave. On top of that, the command is\n> already dumped before it is executed; we don't need to repeat it.\n\nNot sure what you mean: remove the line in case $status = 127, or remove\nit anyway.\n\nIf you mean only when $status = 127, then that is indeed a good idea, as\nthe full error message looks like\n\n  Executing: nosuchcommand\n  zsh:1: command not found: nosuchcommand\n  Execution failed: nosuchcommand\n  You can fix the problem, and then run [...]\n\nSo, yes, the shell's error message is enough and more precise than we\ncould do in git rebase.\n\nIf you mean remove it in any case, I disagree: repeating the command is\nusually not very useful, but may help when the command itself produced a\nlot of output (e.g. \"exec make test\" oftens fills-in your terminal's\nbuffer). And the information that the command fails can be important if\nthe command failed silently, e.g. with \"exec false\":\n\n  Executing: false\n  Execution failed: false\n  You can fix the problem, and then run [...]\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"199404","messageId":"7vtxuvkrbz.fsf@alter.siamese.dyndns.org","threadId":"31584","inReplyTo":"505857CE.3050909@viscovery.net","subject":"Re: [PATCH] rebase -i: fix misleading error message after 'exec no-such' instruction","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-18T20:29:20Z","receivedAt":"2012-09-18T20:29:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> From: Johannes Sixt <j6t@kdbg.org>\n>\n> When the todo sheet of interactive rebase instructs to run a non-existing\n> command, the operation stops with the following error:\n>\n>   Execution failed: no-such\n>   You can fix the problem, and then run\n>\n>           git rebase --continue\n>\n>   fatal: 'rebase' appears to be a git command, but we were not\n>   able to execute it. Maybe git-rebase is broken?\n>\n> The reason is that the shell that attempted to run the command exits with\n> code 127. rebase--interactive just forwards this code to the caller (the\n> git wrapper). But our smart run-command infrastructure detects this\n> special exit code and turns it into ENOENT, which in turn is interpreted\n> by the git wrapper as if the external command that it just executed did\n> not exist.\n\nThat's a funny one ;-)\nWill queue.  Thanks.\n"}]}