Signed-off-by: Martin von Zweigbergk <martinv...@gmail.com>
---
 t/t3421-rebase-topology-linear.sh | 129 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)

diff --git a/t/t3421-rebase-topology-linear.sh 
b/t/t3421-rebase-topology-linear.sh
index f19f0d0..e67add6 100755
--- a/t/t3421-rebase-topology-linear.sh
+++ b/t/t3421-rebase-topology-linear.sh
@@ -218,4 +218,133 @@ test_run_rebase failure -m
 test_run_rebase failure -i
 test_run_rebase failure -p
 
+#       m
+#      /
+# a---b---c---g
+#
+# x---y---B
+#
+# uppercase = cherry-picked
+# m = reverted b
+#
+# Reverted patches are there for tests to be able to check if a commit
+# that introduced the same change as another commit is
+# dropped. Without reverted commits, we could get false positives
+# because applying the patch succeeds, but simply results in no
+# changes.
+test_expect_success 'setup of linear history for test involving root' '
+       git checkout b &&
+       revert m b &&
+       git checkout --orphan disjoint &&
+       git rm -rf . &&
+       test_commit x &&
+       test_commit y &&
+       cherry_pick B b
+'
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* --onto --root" "
+               reset_rebase &&
+               git rebase $* --onto c --root y &&
+               test_cmp_rev c HEAD~2 &&
+               test_linear_range 'x y' c..
+       "
+}
+test_run_rebase success ''
+test_run_rebase failure -m
+test_run_rebase success -i
+test_run_rebase success -p
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* without --onto --root with disjoint 
history" "
+               reset_rebase &&
+               git rebase $* c y &&
+               test_cmp_rev c HEAD~2 &&
+               test_linear_range 'x y' c..
+       "
+}
+test_run_rebase success ''
+test_run_rebase failure -m
+test_run_rebase success -i
+test_run_rebase failure -p
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* --onto --root drops patch in onto" "
+               reset_rebase &&
+               git rebase $* --onto m --root B &&
+               test_cmp_rev m HEAD~2 &&
+               test_linear_range 'x y' m..
+       "
+}
+test_run_rebase success ''
+test_run_rebase failure -m
+test_run_rebase success -i
+test_run_rebase success -p
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* --onto --root with merge-base does not 
go to root" "
+               reset_rebase &&
+               git rebase $* --onto m --root g &&
+               test_cmp_rev m HEAD~2 &&
+               test_linear_range 'c g' m..
+       "
+}
+
+test_run_rebase success ''
+test_run_rebase success -m
+test_run_rebase success -i
+test_run_rebase failure -p
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* without --onto --root with disjoint 
history drops patch in onto" "
+               reset_rebase &&
+               git rebase $* m B &&
+               test_cmp_rev m HEAD~2 &&
+               test_linear_range 'x y' m..
+       "
+}
+test_run_rebase success ''
+test_run_rebase failure -m
+test_run_rebase success -i
+test_run_rebase failure -p
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* --root on linear history is a no-op" "
+               reset_rebase &&
+               git rebase $* --root c &&
+               test_cmp_rev c HEAD
+       "
+}
+test_run_rebase failure ''
+test_run_rebase failure -m
+test_run_rebase failure -i
+test_run_rebase failure -p
+
+test_run_rebase () {
+       result=$1
+       shift
+       test_expect_$result "rebase $* -f --root on linear history causes 
re-write" "
+               reset_rebase &&
+               git rebase $* -f --root c &&
+               ! test_cmp_rev a HEAD~2 &&
+               test_linear_range 'a b c' HEAD
+       "
+}
+test_run_rebase success ''
+test_run_rebase success -m
+test_run_rebase success -i
+test_run_rebase success -p
+
 test_done
-- 
1.8.3.497.g83fddbe

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to