git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rebase -i: only automatically amend commit if HEAD did not change
@ 2008-07-22 21:36 Johannes Schindelin
  2008-07-22 21:48 ` Stephan Beyer
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Johannes Schindelin @ 2008-07-22 21:36 UTC (permalink / raw)
  To: git, gitster


If the user called "rebase -i", marked a commit as "edit", "rebase
--continue" would automatically amend the commit when there were
staged changes.

However, this is actively wrong when the current commit is not the
one marked with "edit".  So guard against this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-rebase--interactive.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index e63a864..444f393 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -276,7 +276,7 @@ do_next () {
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
 		make_patch $sha1
-		: > "$DOTEST"/amend
+		git rev-parse HEAD > "$DOTEST"/amend
 		warn
 		warn "You can amend the commit now, with"
 		warn
@@ -419,7 +419,9 @@ do
 		else
 			. "$DOTEST"/author-script ||
 				die "Cannot find the author identity"
-			if test -f "$DOTEST"/amend
+			if test -f "$DOTEST"/amend &&
+				test $(git rev-parse HEAD) = \
+					$(cat "$DOTEST"/amend)
 			then
 				git reset --soft HEAD^ ||
 				die "Cannot rewind the HEAD"
-- 
1.6.0.rc0.22.gf2096d.dirty

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

end of thread, other threads:[~2008-07-25 10:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 21:36 [PATCH] rebase -i: only automatically amend commit if HEAD did not change Johannes Schindelin
2008-07-22 21:48 ` Stephan Beyer
2008-07-22 22:22 ` Avery Pennarun
2008-07-22 23:55   ` Junio C Hamano
2008-07-23 15:55     ` Avery Pennarun
2008-07-23 12:01   ` Dmitry Potapov
2008-07-23 15:53     ` Avery Pennarun
2008-07-23 16:09       ` Johannes Schindelin
2008-07-23 16:19         ` Avery Pennarun
2008-07-23 23:41 ` Junio C Hamano
2008-07-24 12:20   ` Johannes Schindelin
2008-07-24 12:35     ` Stephan Beyer
2008-07-25  8:44     ` Junio C Hamano
2008-07-25 10:35       ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).