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

[PATCH] rebase-i-p: if todo was reordered use HEAD as the rewritten parent

From
Stephen Haberman <stephen@exigencecorp.com>
Date
Oct 15, 2008, 07:44 UTC
Message-ID
<130c9caae646675893ed17cd213c53a9734fe837.1224055978.git.stephen@exigencecorp.com>
In-Reply-To
<3fd41e60ed27b248f15c60d5a45e543a7e32af99.1224055978.git.stephen@exigencecorp.com>

This seems like the best guess we can make until git sequencer marks are available. That being said, within the context of re-ordering a commit before its parent in todo, I think applying it on top of the current commit seems like a reasonable assumption of what the user intended.

Signed-off-by: Stephen Haberman <stephen@exigencecorp.com>
---
 git-rebase--interactive.sh               |    9 +++++++++
 t/t3411-rebase-preserve-around-merges.sh |    4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 3821692..1fc4f44 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -194,6 +194,15 @@ pick_one_preserving_merges () {
 		if test -f "$REWRITTEN"/$p
 		then
 			new_p=$(cat "$REWRITTEN"/$p)
+
+			# If the todo reordered commits, and our parent is marked for
+			# rewriting, but hasn't been gotten to yet, assume the user meant to
+			# drop it on top of the current HEAD
+			if test -z "$new_p"
+			then
+				new_p=$(git rev-parse HEAD)
+			fi
+
 			test $p != $new_p && fast_forward=f
 			case "$new_parents" in
 			*$new_p*)
diff --git a/t/t3411-rebase-preserve-around-merges.sh b/t/t3411-rebase-preserve-around-merges.sh
index b3973c9..dfad5dd 100644
--- a/t/t3411-rebase-preserve-around-merges.sh
+++ b/t/t3411-rebase-preserve-around-merges.sh
@@ -80,7 +80,7 @@ test_expect_success 'setup' '
 #       \        /
 #        -- C1 --
 #
-test_expect_failure 'squash F1 into D1' '
+test_expect_success 'squash F1 into D1' '
 	FAKE_LINES="1 squash 3 2" git rebase -i -p B1 &&
 	test "$(git rev-parse HEAD^2)" = "$(git rev-parse branch)" &&
 	test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
@@ -99,7 +99,7 @@ test_expect_failure 'squash F1 into D1' '
 #
 # And rebase G1..M1 onto E2
 
-test_expect_failure 'rebase two levels of merge' '
+test_expect_success 'rebase two levels of merge' '
 	git checkout -b branch2 A1 &&
 	touch g &&
 	git add g &&
-- 
1.6.0.2
Previous: Stephen HabermanNext: Jeff King
Message 8 of 18 in “rebase-i-p: squashing and limiting todo”
  1. rebase-i-p: squashing and limiting todoStephen Haberman, Oct 15, 2008
  2. rebase-i-p: test to exclude commits from todo based on its parentsStephen Haberman, Oct 15, 2008
  3. rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEADStephen Haberman, Oct 15, 2008
  4. rebase-i-p: delay saving current-commit to REWRITTEN if squashingStephen Haberman, Oct 15, 2008
  5. rebase-i-p: fix 'no squashing merges' tripping up non-mergesStephen Haberman, Oct 15, 2008
  6. rebase-i-p: only list commits that require rewriting in todoStephen Haberman, Oct 15, 2008
  7. rebase-i-p: do not include non-first-parent commits touching UPSTREAMStephen Haberman, Oct 15, 2008
  8. rebase-i-p: if todo was reordered use HEAD as the rewritten parentStephen Haberman, Oct 15, 2008
  9. Jeff KingOct 20, 2008
  10. Junio C HamanoOct 20, 2008
  11. Jeff KingOct 21, 2008
  12. Stephen HabermanOct 22, 2008
  13. Junio C HamanoOct 22, 2008
  14. Jeff KingOct 22, 2008
  15. Johannes SchindelinOct 22, 2008
  16. Fredrik SkolmliOct 22, 2008
  17. Junio C HamanoOct 22, 2008
  18. Jeff KingOct 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.