threads / patch / 12812

patch, 3 partsAdd test for rebase interactive with preserve merges

Subject: [PATCH 1/3] Add test for rebase interactive with preserve merges

## tl;dr

4 messages between Mar 22, 2008 and Mar 22, 2008. Diffs are folded; open one to read it.

replies: 3people: 1as markdown or json

Jörg Sommer· Mar 22, 2008, 21:44 UTC · lore

The intention of “edit … --continue” is to ensure the state is persistent and not saved in internal variables.

Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
 t/t3404-rebase-interactive.sh |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
Show changes to t/t3404-rebase-interactive.sh +11 −0
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 9cf873f..014b036 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -212,6 +212,17 @@ test_expect_success 'preserve merges with -p' '
 	test $(git show HEAD~2:file1) = B
 '
 
+test_expect_failure 'preserve merges with -p (case 2)' '
+	old_head=$(git rev-parse HEAD) &&
+	test_tick &&
+	EXPECT_COUNT=4 FAKE_LINES="1 4 3 edit 2" git rebase -i -p branch1 &&
+	git rebase --continue &&
+	test $(git rev-parse HEAD) != $old_head
+'
+
+# clean-up from the above test
+git reset -q --hard
+
 test_expect_success '--continue tries to commit' '
 	test_tick &&
 	! git rebase -i --onto new-branch1 HEAD^ &&
-- 
1.5.4.4
Jörg Sommer· Mar 22, 2008, 21:44 UTC · re: Jörg Sommer · lore

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

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(-)
Show changes to git-rebase--interactive.sh +8 −3
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
Jörg Sommer· Mar 22, 2008, 21:44 UTC · re: Jörg Sommer · lore

[PATCH 3/3] Improve failure test for preserve merges

Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
 t/t3404-rebase-interactive.sh |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
Show changes to t/t3404-rebase-interactive.sh +6 −4
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 014b036..eaa2fc0 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -213,11 +213,13 @@ test_expect_success 'preserve merges with -p' '
 '
 
 test_expect_failure 'preserve merges with -p (case 2)' '
-	old_head=$(git rev-parse HEAD) &&
 	test_tick &&
-	EXPECT_COUNT=4 FAKE_LINES="1 4 3 edit 2" git rebase -i -p branch1 &&
-	git rebase --continue &&
-	test $(git rev-parse HEAD) != $old_head
+	EXPECT_COUNT=4 FAKE_LINES="1 4 3 edit 2" git rebase -i -v -p branch1 &&
+	git rebase --continue
+	test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) &&
+	test $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&
+	test $(git show HEAD:file1) = B &&
+	test $(git show HEAD~2:file1) = C
 '
 
 # clean-up from the above test
-- 
1.5.4.4
Jörg Sommer· Mar 22, 2008, 21:57 UTC · re: Jörg Sommer · lore

Re: [PATCH 3/3] Improve failure test for preserve merges

Jörg Sommer schrieb am Sat 22. Mar, 22:44 (+0100):
Show 14 quoted lines
> 
> Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
> ---
>  t/t3404-rebase-interactive.sh |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index 014b036..eaa2fc0 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -213,11 +213,13 @@ test_expect_success 'preserve merges with -p' '
>  '
>  
>  test_expect_failure 'preserve merges with -p (case 2)' '

This test still fails, but I don't know how to fix it. The situation is this:

o---P
 \   \
  A---M---B

A and B should get exchanged. So I would assume that telling rebase the following should do it:

pick P pick B pick M pick A

But what should be the new parent of B?

Is it allowed to permute lines with preserve merges? I've got the impression it's not.

Bye, Jörg.
-- 
[dpkg] We are the apt. Resistance is futile. You will be packaged.

← back to recent threads