Skip to content

Commit

Permalink
rebase -i: clean error message for --continue after failed exec
Browse files Browse the repository at this point in the history
After an "exec false" stops the rebase and gives the control back to
the user, if changes are added to the index, "rebase --continue" fails
with this message, which may technically be correct, but does not point
at the real problem:

.../git-rebase--interactive: line 774: .../.git/rebase-merge/author-script: No such file or directory

We could try auto-amending HEAD, but this goes against the logic of
.git/rebase-merge/author-script (see also the testcase 'auto-amend only
edited commits after "edit"' in t3404-rebase-interactive.sh) to
auto-amend something the user hasn't explicitely asked to edit.

Instead of doing anything automatically, detect the situation and give a
clean error message. While we're there, also clarify the error message in
case '. "$author_script"' fails, which now corresponds to really weird
senario where the author script exists but can't be read.

Test-case-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Matthieu Moy authored and Junio C Hamano committed Aug 26, 2011
1 parent cd2b8ae commit ffaaed8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
18 changes: 17 additions & 1 deletion git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,24 @@ continue)
then
: Nothing to commit -- skip this
else
if ! test -f "$author_script"
then
die "You have staged changes in your working tree. If these changes are meant to be
squashed into the previous commit, run:
git commit --amend
If they are meant to go into a new commit, run:
git commit
In both case, once you're done, continue with:
git rebase --continue
"
fi
. "$author_script" ||
die "Cannot find the author identity"
die "Error trying to find the author identity to amend commit"
current_head=
if test -f "$amend"
then
Expand Down
14 changes: 14 additions & 0 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,20 @@ test_expect_success 'auto-amend only edited commits after "edit"' '
git rebase --abort
'

test_expect_success 'clean error after failed "exec"' '
test_tick &&
test_when_finished "git rebase --abort || :" &&
(
FAKE_LINES="1 exec_false" &&
export FAKE_LINES &&
test_must_fail git rebase -i HEAD^
) &&
echo "edited again" > file7 &&
git add file7 &&
test_must_fail git rebase --continue 2>error &&
grep "You have staged changes in your working tree." error
'

test_expect_success 'rebase a detached HEAD' '
grandparent=$(git rev-parse HEAD~2) &&
git checkout $(git rev-parse HEAD) &&
Expand Down

0 comments on commit ffaaed8

Please sign in to comment.