add tests for rebasing with patch-equivalence present

Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin von Zweigbergk committed Jun 6, 2013 at 23:11 UTC 5b5e1c7c7875bcaed7e640dd0d33de3dbe87e1bb
2 files changed +102
t/lib-rebase.sh
+17
@@ -81,3 +81,20 @@ reset_rebase () {
81 git reset --hard &&
82 git clean -f
83 }
84 +
85 +cherry_pick () {
86 + git cherry-pick -n "$2" &&
87 + git commit -m "$1" &&
88 + git tag "$1"
89 +}
90 +
91 +revert () {
92 + git revert -n "$2" &&
93 + git commit -m "$1" &&
94 + git tag "$1"
95 +}
96 +
97 +make_empty () {
98 + git commit --allow-empty -m "$1" &&
99 + git tag "$1"
100 +}
t/t3421-rebase-topology-linear.sh
+85
@@ -75,4 +75,89 @@ test_run_rebase success -m
75 test_run_rebase success -i
76 test_run_rebase success -p
77
78 +# f
79 +# /
80 +# a---b---c---g---h
81 +# \
82 +# d---G---i
83 +#
84 +# uppercase = cherry-picked
85 +# h = reverted g
86 +#
87 +# Reverted patches are there for tests to be able to check if a commit
88 +# that introduced the same change as another commit is
89 +# dropped. Without reverted commits, we could get false positives
90 +# because applying the patch succeeds, but simply results in no
91 +# changes.
92 +test_expect_success 'setup of linear history for range selection tests' '
93 + git checkout c &&
94 + test_commit g &&
95 + revert h g &&
96 + git checkout d &&
97 + cherry_pick G g &&
98 + test_commit i &&
99 + git checkout b &&
100 + test_commit f
101 +'
102 +
103 +test_run_rebase () {
104 + result=$1
105 + shift
106 + test_expect_$result "rebase $* drops patches in upstream" "
107 + reset_rebase &&
108 + git rebase $* h i &&
109 + test_cmp_rev h HEAD~2 &&
110 + test_linear_range 'd i' h..
111 + "
112 +}
113 +test_run_rebase success ''
114 +test_run_rebase failure -m
115 +test_run_rebase success -i
116 +test_run_rebase success -p
117 +
118 +test_run_rebase () {
119 + result=$1
120 + shift
121 + test_expect_$result "rebase $* can drop last patch if in upstream" "
122 + reset_rebase &&
123 + git rebase $* h G &&
124 + test_cmp_rev h HEAD^ &&
125 + test_linear_range 'd' h..
126 + "
127 +}
128 +test_run_rebase success ''
129 +test_run_rebase failure -m
130 +test_run_rebase success -i
131 +test_run_rebase success -p
132 +
133 +test_run_rebase () {
134 + result=$1
135 + shift
136 + test_expect_$result "rebase $* --onto drops patches in upstream" "
137 + reset_rebase &&
138 + git rebase $* --onto f h i &&
139 + test_cmp_rev f HEAD~2 &&
140 + test_linear_range 'd i' f..
141 + "
142 +}
143 +test_run_rebase success ''
144 +test_run_rebase failure -m
145 +test_run_rebase success -i
146 +test_run_rebase success -p
147 +
148 +test_run_rebase () {
149 + result=$1
150 + shift
151 + test_expect_$result "rebase $* --onto does not drop patches in onto" "
152 + reset_rebase &&
153 + git rebase $* --onto h f i &&
154 + test_cmp_rev h HEAD~3 &&
155 + test_linear_range 'd G i' h..
156 + "
157 +}
158 +test_run_rebase success ''
159 +test_run_rebase success -m
160 +test_run_rebase success -i
161 +test_run_rebase success -p
162 +
163 test_done