All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] git-rebase-interactive: do not squash commits on abort
@ 2008-09-08 20:42 Dmitry Potapov
  2008-09-08 20:42 ` [PATCH 2/2] git-rebase--interactive: auto amend only edited commit Dmitry Potapov
  2008-09-09  0:06 ` [PATCH 1/2] git-rebase-interactive: do not squash commits on abort Junio C Hamano
  0 siblings, 2 replies; 12+ messages in thread
From: Dmitry Potapov @ 2008-09-08 20:42 UTC (permalink / raw)
  To: Junio C Hamano, git; +Cc: Dmitry Potapov

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>
---
 git-rebase--interactive.sh |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 929d681..5b2b1e5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -429,12 +429,15 @@ do
 				die "Cannot find the author identity"
 			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
-- 
1.6.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-09-10 22:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-08 20:42 [PATCH 1/2] git-rebase-interactive: do not squash commits on abort Dmitry Potapov
2008-09-08 20:42 ` [PATCH 2/2] git-rebase--interactive: auto amend only edited commit Dmitry Potapov
2008-09-09  0:33   ` Junio C Hamano
2008-09-09  7:00     ` Dmitry Potapov
2008-09-09 12:05       ` [PATCH v2] " Dmitry Potapov
2008-09-09  6:42   ` [PATCH 2/2] " Johannes Sixt
2008-09-09  7:30     ` Dmitry Potapov
2008-09-09  0:06 ` [PATCH 1/2] git-rebase-interactive: do not squash commits on abort Junio C Hamano
2008-09-09 14:17   ` Johannes Schindelin
2008-09-09 20:50     ` [PATCH v2] " Dmitry Potapov
2008-09-10  9:53       ` Johannes Schindelin
2008-09-10 22:36         ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.