rebase -i: fix misleading error message after 'exec no-such' instruction

When the todo sheet of interactive rebase instructs to run a non-existing command, the operation stops with the following error: Execution failed: no-such You can fix the problem, and then run git rebase --continue fatal: 'rebase' appears to be a git command, but we were not able to execute it. Maybe git-rebase is broken? The reason is that the shell that attempted to run the command exits with code 127. rebase--interactive just forwards this code to the caller (the git wrapper). But our smart run-command infrastructure detects this special exit code and turns it into ENOENT, which in turn is interpreted by the git wrapper as if the external command that it just executed did not exist. This is finally translated to the misleading last two lines in error message cited above. Fix it by translating the error code before it is forwarded. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Sep 18, 2012 at 13:15 UTC ecfe1ea96fde1fa5756ad04f717fd2960ead988a
2 files changed +15
git-rebase--interactive.sh
+4
@@ -544,6 +544,10 @@ do_next () {
544 warn
545 warn " git rebase --continue"
546 warn
547 + if test $status -eq 127 # command not found
548 + then
549 + status=1
550 + fi
551 exit "$status"
552 elif test "$dirty" = t
553 then
t/t3404-rebase-interactive.sh
+11
@@ -118,6 +118,17 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
118 git rebase --continue
119 '
120
121 +test_expect_success 'rebase -i with exec of inexistent command' '
122 + git checkout master &&
123 + test_when_finished "git rebase --abort" &&
124 + (
125 + FAKE_LINES="exec_this-command-does-not-exist 1" &&
126 + export FAKE_LINES &&
127 + test_must_fail git rebase -i HEAD^ >actual 2>&1
128 + ) &&
129 + ! grep "Maybe git-rebase is broken" actual
130 +'
131 +
132 test_expect_success 'no changes are a nop' '
133 git checkout branch2 &&
134 git rebase -i F &&