@matheusbsbs / matheus-bagliano / commits / 8beb1f33d1
Fork 0

git-rebase-interactive: do not squash commits on abort

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>

Dmitry Potapov committed Sep 9, 2008 at 00:42 UTC 8beb1f33d15af6cdb6bf7d8296fd73eb8df2f152
1 file changed +6 -2
git-rebase--interactive.sh
+6 -2
@@ -427,14 +427,18 @@ do
427 else
428 . "$DOTEST"/author-script ||
429 die "Cannot find the author identity"
430 + amend=
431 if test -f "$DOTEST"/amend
432 then
433 + amend=$(git rev-parse --verify HEAD)
434 git reset --soft HEAD^ ||
435 die "Cannot rewind the HEAD"
436 fi
437 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
436 - git commit --no-verify -F "$DOTEST"/message -e ||
437 - die "Could not commit staged changes."
438 + git commit --no-verify -F "$DOTEST"/message -e || {
439 + test -n "$amend" && git reset --soft $amend
440 + die "Could not commit staged changes."
441 + }
442 fi
443
444 require_clean_work_tree