Skip to content

Commit

Permalink
rebase -i: fix misleading error message after 'exec no-such' instruction
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Sep 18, 2012
1 parent 5805853 commit ecfe1ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ do_next () {
warn
warn " git rebase --continue"
warn
if test $status -eq 127 # command not found
then
status=1
fi
exit "$status"
elif test "$dirty" = t
then
Expand Down
11 changes: 11 additions & 0 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
git rebase --continue
'

test_expect_success 'rebase -i with exec of inexistent command' '
git checkout master &&
test_when_finished "git rebase --abort" &&
(
FAKE_LINES="exec_this-command-does-not-exist 1" &&
export FAKE_LINES &&
test_must_fail git rebase -i HEAD^ >actual 2>&1
) &&
! grep "Maybe git-rebase is broken" actual
'

test_expect_success 'no changes are a nop' '
git checkout branch2 &&
git rebase -i F &&
Expand Down

0 comments on commit ecfe1ea

Please sign in to comment.