git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] Change rebase with preserver merges to pick up the right new HEAD

From
JSJörg Sommer <joerg@alea.gnuu.de>
Date
Mar 22, 2008, 21:44 UTC
Message-ID
<1206222266-29179-2-git-send-email-joerg@alea.gnuu.de>
In-Reply-To
<1206222266-29179-1-git-send-email-joerg@alea.gnuu.de>

The assumtion that the new HEAD is the rewritten old head is wrong. The new HEAD is the (maybe rewritten) last commit in the list.

Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
 git-rebase--interactive.sh |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 8aa7371..dec18a3 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -20,6 +20,7 @@ require_work_tree
 DOTEST="$GIT_DIR/.dotest-merge"
 TODO="$DOTEST"/git-rebase-todo
 DONE="$DOTEST"/done
+LAST_SHA1="$DOTEST"/last_sha1
 MSG="$DOTEST"/message
 SQUASH_MSG="$DOTEST"/message-squash
 REWRITTEN="$DOTEST"/rewritten
@@ -251,6 +252,7 @@ do_next () {
 	pick|p)
 		comment_for_reflog pick
 
+		echo $sha1 > "$LAST_SHA1"
 		mark_action_done
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
@@ -258,6 +260,7 @@ do_next () {
 	edit|e)
 		comment_for_reflog edit
 
+		echo $sha1 > "$LAST_SHA1"
 		mark_action_done
 		pick_one $sha1 ||
 			die_with_patch $sha1 "Could not apply $sha1... $rest"
@@ -280,6 +283,7 @@ do_next () {
 		has_action "$DONE" ||
 			die "Cannot 'squash' without a previous commit"
 
+		echo $sha1 > "$LAST_SHA1"
 		mark_action_done
 		make_squash_message $sha1 > "$MSG"
 		case "$(peek_next_command)" in
@@ -333,11 +337,12 @@ do_next () {
 		test -f "$DOTEST"/current-commit &&
 			current_commit=$(cat "$DOTEST"/current-commit) &&
 			git rev-parse HEAD > "$REWRITTEN"/$current_commit
-		if test -f "$REWRITTEN"/$OLDHEAD
+		last_sha1=$(git rev-parse $(cat "$LAST_SHA1"))
+		if test -f "$REWRITTEN"/$last_sha1
 		then
-			NEWHEAD=$(cat "$REWRITTEN"/$OLDHEAD)
+			NEWHEAD=$(cat "$REWRITTEN"/$last_sha1)
 		else
-			NEWHEAD=$OLDHEAD
+			NEWHEAD=$last_sha1
 		fi
 	else
 		NEWHEAD=$(git rev-parse HEAD)
-- 
1.5.4.4
Previous: Jörg SommerNext: Jörg Sommer
Message 2 of 4 in “Add test for rebase interactive with preserve merges”
  1. 1/3 Add test for rebase interactive with preserve mergesJörg Sommer, Mar 22, 2008
  2. 2/3 Change rebase with preserver merges to pick up the right new HEADJörg Sommer, Mar 22, 2008
  3. 3/3 Improve failure test for preserve mergesJörg Sommer, Mar 22, 2008
  4. Jörg SommerMar 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.