Skip to content

Commit

Permalink
git-rebase-interactive: do not squash commits on abort
Browse files Browse the repository at this point in the history
If git rebase interactive is stopped by "edit" command and then the user
said "git rebase --continue" while having some stage changes, git rebase
interactive is trying to amend the last commit by doing:
  git --soft reset && git commit

However, the user can abort commit for some reason by providing an empty
log message, and that would leave the last commit undone, while the user
being completely unaware about what happened. Now if the user tries to
continue, by issuing "git rebase --continue" that squashes two previous
commits.

Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Dmitry Potapov authored and Junio C Hamano committed Sep 9, 2008
1 parent aaefbfa commit 8beb1f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions git-rebase--interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,18 @@ do
else
. "$DOTEST"/author-script ||
die "Cannot find the author identity"
amend=
if test -f "$DOTEST"/amend
then
amend=$(git rev-parse --verify HEAD)
git reset --soft HEAD^ ||
die "Cannot rewind the HEAD"
fi
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
git commit --no-verify -F "$DOTEST"/message -e ||
die "Could not commit staged changes."
git commit --no-verify -F "$DOTEST"/message -e || {
test -n "$amend" && git reset --soft $amend
die "Could not commit staged changes."
}
fi

require_clean_work_tree
Expand Down

0 comments on commit 8beb1f3

Please sign in to comment.