All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin von Zweigbergk <martinvonz@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Sixt <j.sixt@viscovery.net>,
	Chris Webb <chris@arachsys.com>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Martin von Zweigbergk <martinvonz@gmail.com>
Subject: [PATCH v2 5/7] add tests for rebasing merged history
Date: Tue, 28 May 2013 23:39:30 -0700	[thread overview]
Message-ID: <1369809572-24431-6-git-send-email-martinvonz@gmail.com> (raw)
In-Reply-To: <1369809572-24431-1-git-send-email-martinvonz@gmail.com>

---
 t/t3400-rebase.sh                 |  31 +----
 t/t3401-rebase-partial.sh         |  45 -------
 t/t3404-rebase-interactive.sh     |  10 +-
 t/t3409-rebase-preserve-merges.sh |  53 --------
 t/t3425-rebase-topology-merges.sh | 250 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 252 insertions(+), 137 deletions(-)
 delete mode 100755 t/t3401-rebase-partial.sh
 create mode 100755 t/t3425-rebase-topology-merges.sh

diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index b58fa1a..b436ef4 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -40,13 +40,6 @@ test_expect_success 'prepare repository with topic branches' '
 	echo Side >>C &&
 	git add C &&
 	git commit -m "Add C" &&
-	git checkout -b nonlinear my-topic-branch &&
-	echo Edit >>B &&
-	git add B &&
-	git commit -m "Modify B" &&
-	git merge side &&
-	git checkout -b upstream-merged-nonlinear &&
-	git merge master &&
 	git checkout -f my-topic-branch &&
 	git tag topic
 '
@@ -106,31 +99,9 @@ test_expect_success 'rebase from ambiguous branch name' '
 	git rebase master
 '
 
-test_expect_success 'rebase after merge master' '
-	git checkout --detach refs/tags/topic &&
-	git branch -D topic &&
-	git reset --hard topic &&
-	git merge master &&
-	git rebase master &&
-	! (git show | grep "^Merge:")
-'
-
-test_expect_success 'rebase of history with merges is linearized' '
-	git checkout nonlinear &&
-	test 4 = $(git rev-list master.. | wc -l) &&
-	git rebase master &&
-	test 3 = $(git rev-list master.. | wc -l)
-'
-
-test_expect_success 'rebase of history with merges after upstream merge is linearized' '
-	git checkout upstream-merged-nonlinear &&
-	test 5 = $(git rev-list master.. | wc -l) &&
-	git rebase master &&
-	test 3 = $(git rev-list master.. | wc -l)
-'
-
 test_expect_success 'rebase a single mode change' '
 	git checkout master &&
+	git branch -D topic &&
 	echo 1 >X &&
 	git add X &&
 	test_tick &&
diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh
deleted file mode 100755
index 7ba1797..0000000
--- a/t/t3401-rebase-partial.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland
-#
-
-test_description='git rebase should detect patches integrated upstream
-
-This test cherry-picks one local change of two into master branch, and
-checks that git rebase succeeds with only the second patch in the
-local branch.
-'
-. ./test-lib.sh
-
-test_expect_success 'prepare repository with topic branch' '
-	test_commit A &&
-	git checkout -b my-topic-branch &&
-	test_commit B &&
-	test_commit C &&
-	git checkout -f master &&
-	test_commit A2 A.t
-'
-
-test_expect_success 'pick top patch from topic branch into master' '
-	git cherry-pick C &&
-	git checkout -f my-topic-branch
-'
-
-test_debug '
-	git cherry master &&
-	git format-patch -k --stdout --full-index master >/dev/null &&
-	gitk --all & sleep 1
-'
-
-test_expect_success 'rebase topic branch against new master and check git am did not get halted' '
-	git rebase master &&
-	test_path_is_missing .git/rebase-apply
-'
-
-test_expect_success 'rebase --merge topic branch that was partially merged upstream' '
-	git reset --hard C &&
-	git rebase --merge master &&
-	test_path_is_missing .git/rebase-merge
-'
-
-test_done
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index a58406d..ffcaf02 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -477,19 +477,11 @@ test_expect_success 'interrupted squash works as expected (case 2)' '
 	test $one = $(git rev-parse HEAD~2)
 '
 
-test_expect_success 'ignore patch if in upstream' '
-	HEAD=$(git rev-parse HEAD) &&
-	git checkout -b has-cherry-picked HEAD^ &&
+test_expect_success '--continue tries to commit, even for "edit"' '
 	echo unrelated > file7 &&
 	git add file7 &&
 	test_tick &&
 	git commit -m "unrelated change" &&
-	git cherry-pick $HEAD &&
-	EXPECT_COUNT=1 git rebase -i $HEAD &&
-	test $HEAD = $(git rev-parse HEAD^)
-'
-
-test_expect_success '--continue tries to commit, even for "edit"' '
 	parent=$(git rev-parse HEAD^) &&
 	test_tick &&
 	FAKE_LINES="edit 1" git rebase -i HEAD^ &&
diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh
index 6de4e22..2e0c364 100755
--- a/t/t3409-rebase-preserve-merges.sh
+++ b/t/t3409-rebase-preserve-merges.sh
@@ -11,14 +11,6 @@ Run "git rebase -p" and check that merges are properly carried along
 GIT_AUTHOR_EMAIL=bogus_email_address
 export GIT_AUTHOR_EMAIL
 
-# Clone 1 (trivial merge):
-#
-# A1--A2  <-- origin/master
-#  \   \
-#   B1--M  <-- topic
-#    \
-#     B2  <-- origin/topic
-#
 # Clone 2 (conflicting merge):
 #
 # A1--A2--B3   <-- origin/master
@@ -36,16 +28,6 @@ export GIT_AUTHOR_EMAIL
 #     \--A3    <-- topic2
 #      \
 #       B2     <-- origin/topic
-#
-# Clone 4 (merge using second parent as base):
-#
-# A1--A2--B3   <-- origin/master
-#  \
-#   B1--A3--M  <-- topic
-#    \     /
-#     \--A4    <-- topic2
-#      \
-#       B2     <-- origin/topic
 
 test_expect_success 'setup for merge-preserving rebase' \
 	'echo First > A &&
@@ -58,20 +40,6 @@ test_expect_success 'setup for merge-preserving rebase' \
 	git checkout -f master &&
 	echo Third >> A &&
 	git commit -a -m "Modify A2" &&
-
-	git clone ./. clone1 &&
-	(cd clone1 &&
-	git checkout -b topic origin/topic &&
-	git merge origin/master
-	) &&
-
-	git clone ./. clone4 &&
-	(
-		cd clone4 &&
-		git checkout -b topic origin/topic &&
-		git merge origin/master
-	) &&
-
 	echo Fifth > B &&
 	git add B &&
 	git commit -m "Add different B" &&
@@ -101,16 +69,6 @@ test_expect_success 'setup for merge-preserving rebase' \
 	git commit -a -m "Modify B2"
 '
 
-test_expect_success 'rebase -p fakes interactive rebase' '
-	(
-	cd clone1 &&
-	git fetch &&
-	git rebase -p origin/topic &&
-	test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
-	test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
-	)
-'
-
 test_expect_success '--continue works after a conflict' '
 	(
 	cd clone2 &&
@@ -138,15 +96,4 @@ test_expect_success 'rebase -p preserves no-ff merges' '
 	)
 '
 
-test_expect_success 'rebase -p works when base inside second parent' '
-	(
-	cd clone4 &&
-	git fetch &&
-	git rebase -p HEAD^2 &&
-	test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
-	test 1 = $(git rev-list --all --pretty=oneline | grep "Modify B" | wc -l) &&
-	test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote-tracking branch " | wc -l)
-	)
-'
-
 test_done
diff --git a/t/t3425-rebase-topology-merges.sh b/t/t3425-rebase-topology-merges.sh
new file mode 100755
index 0000000..0f56407
--- /dev/null
+++ b/t/t3425-rebase-topology-merges.sh
@@ -0,0 +1,250 @@
+#!/bin/sh
+
+test_description='rebase topology tests with merges'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-rebase.sh
+
+test_revision_subjects () {
+	expected="$1"
+	shift
+	set -- $(git log --format=%s --no-walk=unsorted "$@")
+	test "$expected" = "$*"
+}
+
+# a---b-----------c
+#      \           \
+#       d-------e   \
+#        \       \   \
+#         n---o---w---v
+#              \
+#               z
+#
+# uppercase = cherry-picked
+test_expect_success 'setup of non-linear-history' '
+	test_commit a &&
+	test_commit b &&
+	test_commit c &&
+	git checkout b &&
+	test_commit d &&
+	test_commit e
+
+	git checkout c &&
+	test_commit g &&
+	revert h g &&
+	git checkout d &&
+	cherry_pick G g &&
+	test_commit i &&
+	git checkout b &&
+	test_commit f
+
+	git checkout d &&
+	test_commit n &&
+	test_commit o &&
+	test_merge w e &&
+	test_merge v c &&
+	git checkout o &&
+	test_commit z
+'
+
+test_run_rebase () {
+	result=$1
+	shift
+	test_expect_$result "rebase $* after merge from upstream" "
+		reset_rebase &&
+		git rebase $* e w &&
+		test_cmp_rev e HEAD~2 &&
+		test_linear_range 'n o' e..
+	"
+}
+test_run_rebase success ''
+test_run_rebase success -m
+test_run_rebase success -i
+
+test_run_rebase () {
+	result=$1
+	shift
+	expected=$1
+	shift
+	test_expect_$result "rebase $* of non-linear history is linearized in place" "
+		reset_rebase &&
+		git rebase $* d w &&
+		test_cmp_rev d HEAD~3 &&
+		test_linear_range "\'"$expected"\'" d..
+	"
+}
+#TODO: make all flavors of rebase use --topo-order
+test_run_rebase success 'e n o' ''
+test_run_rebase success 'e n o' -m
+test_run_rebase success 'n o e' -i
+
+test_run_rebase () {
+	result=$1
+	shift
+	expected=$1
+	shift
+	test_expect_$result "rebase $* of non-linear history is linearized upstream" "
+		reset_rebase &&
+		git rebase $* c w &&
+		test_cmp_rev c HEAD~4 &&
+		test_linear_range "\'"$expected"\'" c..
+	"
+}
+#TODO: make all flavors of rebase use --topo-order
+test_run_rebase success 'd e n o' ''
+test_run_rebase success 'd e n o' -m
+test_run_rebase success 'd n o e' -i
+
+test_run_rebase () {
+	result=$1
+	shift
+	expected=$1
+	shift
+	test_expect_$result "rebase $* of non-linear history with merges after upstream merge is linearized" "
+		reset_rebase &&
+		git rebase $* c v &&
+		test_cmp_rev c HEAD~4 &&
+		test_linear_range "\'"$expected"\'" c..
+	"
+}
+#TODO: make all flavors of rebase use --topo-order
+test_run_rebase success 'd e n o' ''
+test_run_rebase success 'd e n o' -m
+test_run_rebase success 'd n o e' -i
+
+test_expect_success "rebase -p is no-op in non-linear history" "
+	reset_rebase &&
+	git rebase -p d w &&
+	test_cmp_rev w HEAD
+"
+
+test_expect_success "rebase -p is no-op when base inside second parent" "
+	reset_rebase &&
+	git rebase -p e w &&
+	test_cmp_rev w HEAD
+"
+
+test_expect_failure "rebase -p --root on non-linear history is a no-op" "
+	reset_rebase &&
+	git rebase -p --root w &&
+	test_cmp_rev w HEAD
+"
+
+test_expect_success "rebase -p re-creates merge from side branch" "
+	reset_rebase &&
+	git rebase -p z w &&
+	test_cmp_rev z HEAD^ &&
+	test_cmp_rev w^2 HEAD^2
+"
+
+test_expect_success "rebase -p re-creates internal merge" "
+	reset_rebase &&
+	git rebase -p c w &&
+	test_revision_subjects 'c d n e o w' HEAD~4 HEAD~3 HEAD~2 HEAD^2 HEAD^ HEAD
+"
+
+test_expect_success "rebase -p can re-create two branches on onto" "
+	reset_rebase &&
+	git rebase -p --onto c d w &&
+	test_revision_subjects 'c n e o w' HEAD~3 HEAD~2 HEAD^2 HEAD^ HEAD
+"
+
+#       f
+#      /
+# a---b---c---g---h
+#      \
+#       d---G---i
+#        \       \
+#         e-------u
+#
+# uppercase = cherry-picked
+# h = reverted g
+test_expect_success 'setup of non-linear-history for patch-equivalence tests' '
+	git checkout e &&
+	test_merge u i
+'
+
+test_expect_success "rebase -p re-creates history around dropped commit matching upstream" "
+	reset_rebase &&
+	git rebase -p h u &&
+	test_cmp_rev h HEAD~3 &&
+	test_revision_subjects 'd i e u' HEAD~2 HEAD^2 HEAD^ HEAD
+"
+
+test_expect_failure "rebase -p --onto in merged history does not lose patches in upstream" "
+	reset_rebase &&
+	git rebase -p --onto f h u &&
+	test_cmp_rev f HEAD~3 &&
+	test_revision_subjects 'd G i e u' HEAD~2 HEAD^2^ HEAD^2 HEAD^ HEAD
+"
+
+test_expect_success "rebase -p --onto in merged history drops patches in onto" "
+	reset_rebase &&
+	git rebase -p --onto h f u &&
+	test_cmp_rev h HEAD~3 &&
+	test_revision_subjects 'd i e u' HEAD~2 HEAD^2 HEAD^ HEAD
+"
+
+# a---b---c---g---h
+#      \
+#       d---G---s
+#        \   \ /
+#         \   X
+#          \ / \
+#           e---t
+#
+# uppercase = cherry-picked
+# h = reverted g
+test_expect_success 'setup of non-linear-history for dropping whole side' '
+	git checkout G &&
+	test_merge s e &&
+	git checkout e &&
+	test_merge t G
+'
+
+test_expect_failure "rebase -p drops merge commit when entire first-parent side is dropped" "
+	reset_rebase &&
+	git rebase -p h s &&
+	test_cmp_rev h HEAD~2 &&
+	test_linear_range 'd e' h..
+"
+
+test_expect_success "rebase -p drops merge commit when entire second-parent side is dropped" "
+	reset_rebase &&
+	git rebase -p h t &&
+	test_cmp_rev h HEAD~2 &&
+	test_linear_range 'd e' h..
+"
+
+# a---b---c
+#      \
+#       d---e
+#        \   \
+#         n---r
+#          \
+#           o
+#
+# r = tree-same with n
+# uppercace = cherry-picked
+test_expect_success 'setup of non-linear-history for empty commits' '
+	git checkout n &&
+	git merge --no-commit e &&
+	git reset n . &&
+	git commit -m r &&
+	git reset --hard &&
+	git clean -f &&
+	git tag r
+'
+
+test_expect_success "rebase -p re-creates empty internal merge commit" "
+	reset_rebase &&
+	git rebase -p c r &&
+	test_revision_subjects 'c d e n r' HEAD~3 HEAD~2 HEAD^2 HEAD^ HEAD
+"
+
+test_expect_success "rebase -p re-creates empty merge commit" "
+	reset_rebase &&
+	git rebase -p o r &&
+	test_revision_subjects 'e o r' HEAD^2 HEAD^ HEAD
+"
+
+test_done
-- 
1.8.2.674.gd17d3d2

  parent reply	other threads:[~2013-05-29  6:41 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18  6:31 [RFC PATCH] add t3420-rebase-topology Martin von Zweigbergk
2012-09-18  7:51 ` Junio C Hamano
2012-09-21 17:06   ` Martin von Zweigbergk
2012-09-18  7:53 ` Johannes Sixt
2012-09-26 17:07   ` Martin von Zweigbergk
2012-09-27 12:20     ` Chris Webb
2012-09-28 18:03       ` Martin von Zweigbergk
2012-09-29  8:08         ` Chris Webb
2013-05-29  6:39 ` [PATCH v2 0/7] Rebase topology test Martin von Zweigbergk
2013-05-29  6:39   ` [PATCH v2 1/7] add simple tests of consistency across rebase types Martin von Zweigbergk
2013-06-03 17:16     ` Martin von Zweigbergk
2013-06-03 18:05       ` Junio C Hamano
2013-06-03 18:12         ` Martin von Zweigbergk
2013-05-29  6:39   ` [PATCH v2 2/7] add tests for rebasing with patch-equivalence present Martin von Zweigbergk
2013-05-29  7:09     ` Johannes Sixt
2013-05-30  5:30       ` Martin von Zweigbergk
2013-05-30  5:41         ` Felipe Contreras
2013-05-30  6:14           ` Martin von Zweigbergk
2013-05-30  6:40             ` Felipe Contreras
2013-05-30  6:46               ` Martin von Zweigbergk
2013-05-30 12:54         ` Johannes Sixt
2013-05-30 15:01           ` Martin von Zweigbergk
2013-05-29  6:39   ` [PATCH v2 3/7] add tests for rebasing of empty commits Martin von Zweigbergk
2013-05-29  6:39   ` [PATCH v2 4/7] add tests for rebasing root Martin von Zweigbergk
2013-05-29  7:31     ` Johannes Sixt
2013-05-30  5:51       ` Martin von Zweigbergk
2013-05-29  6:39   ` Martin von Zweigbergk [this message]
2013-05-29  7:57     ` [PATCH v2 5/7] add tests for rebasing merged history Johannes Sixt
2013-05-31  5:42       ` Martin von Zweigbergk
2013-05-29 10:33     ` Johannes Sixt
2013-05-29  6:39   ` [PATCH v2 6/7] t3406: modernize style Martin von Zweigbergk
2013-05-29  6:39   ` [PATCH v2 7/7] tests: move test for rebase messages from t3400 to t3406 Martin von Zweigbergk
2013-05-29  7:10   ` [PATCH v2 0/7] Rebase topology test Felipe Contreras
2013-05-29 12:50     ` Ramkumar Ramachandra
2013-05-29 13:54       ` Felipe Contreras
2013-05-31  6:49   ` [PATCH v3 " Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 1/7] add simple tests of consistency across rebase types Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 2/7] add tests for rebasing with patch-equivalence present Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 3/7] add tests for rebasing of empty commits Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 4/7] add tests for rebasing root Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 5/7] add tests for rebasing merged history Martin von Zweigbergk
2013-05-31 12:19       ` Johannes Sixt
2013-06-01 21:36         ` [PATCH v4 " Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 6/7] t3406: modernize style Martin von Zweigbergk
2013-05-31  6:49     ` [PATCH v3 7/7] tests: move test for rebase messages from t3400 to t3406 Martin von Zweigbergk
2013-06-03 20:42     ` [PATCH v5 0/7] Rebase topology test Martin von Zweigbergk
2013-06-03 20:42       ` [PATCH v5 1/7] add simple tests of consistency across rebase types Martin von Zweigbergk
2013-06-03 22:28         ` Junio C Hamano
2013-06-04  5:14           ` Martin von Zweigbergk
2013-06-04  5:49             ` Junio C Hamano
2013-06-04  6:15             ` Johannes Sixt
2013-06-05  4:31               ` Martin von Zweigbergk
2013-06-03 20:42       ` [PATCH v5 2/7] add tests for rebasing with patch-equivalence present Martin von Zweigbergk
2013-06-03 20:42       ` [PATCH v5 3/7] add tests for rebasing of empty commits Martin von Zweigbergk
2013-06-03 20:42       ` [PATCH v5 4/7] add tests for rebasing root Martin von Zweigbergk
2013-06-03 20:42       ` [PATCH v5 5/7] add tests for rebasing merged history Martin von Zweigbergk
2013-06-04 17:18         ` Junio C Hamano
2013-06-05  5:44           ` Martin von Zweigbergk
2013-06-05  6:12           ` Johannes Sixt
2013-06-03 20:42       ` [PATCH v5 6/7] t3406: modernize style Martin von Zweigbergk
2013-06-03 20:42       ` [PATCH v5 7/7] tests: move test for rebase messages from t3400 to t3406 Martin von Zweigbergk
2013-06-07  6:11       ` [PATCH v6 0/8] Rebase topology test Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 1/7] add simple tests of consistency across rebase types Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 2/7] add tests for rebasing with patch-equivalence present Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 3/7] add tests for rebasing of empty commits Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 4/7] add tests for rebasing root Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 5/7] add tests for rebasing merged history Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 6/7] t3406: modernize style Martin von Zweigbergk
2013-06-07  6:11         ` [PATCH v6 7/7] tests: move test for rebase messages from t3400 to t3406 Martin von Zweigbergk
2013-06-07 16:43         ` [PATCH v6 0/8] Rebase topology test Junio C Hamano
2013-06-07 19:37         ` Johannes Sixt
2013-06-18  7:28         ` [PATCH mz/rebase-tests] rebase topology tests: fix commit names on case-insensitive file systems Johannes Sixt
2013-06-18 15:45           ` Junio C Hamano
2013-06-18 15:53           ` Martin von Zweigbergk
2013-06-19  5:52             ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369809572-24431-6-git-send-email-martinvonz@gmail.com \
    --to=martinvonz@gmail.com \
    --cc=chris@arachsys.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.