add tests for rebasing of empty commits

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 00b8be5a4d383be1f4b6d0c083d3d4b10f38444b
2 files changed +58 -24
t/t3401-rebase-partial.sh
-24
@@ -42,28 +42,4 @@ test_expect_success 'rebase --merge topic branch that was partially merged upstr
42 test_path_is_missing .git/rebase-merge
43 '
44
45 -test_expect_success 'rebase ignores empty commit' '
46 - git reset --hard A &&
47 - git commit --allow-empty -m empty &&
48 - test_commit D &&
49 - git rebase C &&
50 - test "$(git log --format=%s C..)" = "D"
51 -'
52 -
53 -test_expect_success 'rebase --keep-empty' '
54 - git reset --hard D &&
55 - git rebase --keep-empty C &&
56 - test "$(git log --format=%s C..)" = "D
57 -empty"
58 -'
59 -
60 -test_expect_success 'rebase --keep-empty keeps empty even if already in upstream' '
61 - git reset --hard A &&
62 - git commit --allow-empty -m also-empty &&
63 - git rebase --keep-empty D &&
64 - test "$(git log --format=%s A..)" = "also-empty
65 -D
66 -empty"
67 -'
68 -
45 test_done
t/t3421-rebase-topology-linear.sh
+58
@@ -160,4 +160,62 @@ test_run_rebase success -m
160 test_run_rebase success -i
161 test_run_rebase success -p
162
163 +# a---b---c---j!
164 +# \
165 +# d---k!--l
166 +#
167 +# ! = empty
168 +test_expect_success 'setup of linear history for empty commit tests' '
169 + git checkout c &&
170 + make_empty j &&
171 + git checkout d &&
172 + make_empty k &&
173 + test_commit l
174 +'
175 +
176 +test_run_rebase () {
177 + result=$1
178 + shift
179 + test_expect_$result "rebase $* drops empty commit" "
180 + reset_rebase &&
181 + git rebase $* c l &&
182 + test_cmp_rev c HEAD~2 &&
183 + test_linear_range 'd l' c..
184 + "
185 +}
186 +test_run_rebase success ''
187 +test_run_rebase success -m
188 +test_run_rebase success -i
189 +test_run_rebase success -p
190 +
191 +test_run_rebase () {
192 + result=$1
193 + shift
194 + test_expect_$result "rebase $* --keep-empty" "
195 + reset_rebase &&
196 + git rebase $* --keep-empty c l &&
197 + test_cmp_rev c HEAD~3 &&
198 + test_linear_range 'd k l' c..
199 + "
200 +}
201 +test_run_rebase success ''
202 +test_run_rebase failure -m
203 +test_run_rebase success -i
204 +test_run_rebase failure -p
205 +
206 +test_run_rebase () {
207 + result=$1
208 + shift
209 + test_expect_$result "rebase $* --keep-empty keeps empty even if already in upstream" "
210 + reset_rebase &&
211 + git rebase $* --keep-empty j l &&
212 + test_cmp_rev j HEAD~3 &&
213 + test_linear_range 'd k l' j..
214 + "
215 +}
216 +test_run_rebase success ''
217 +test_run_rebase failure -m
218 +test_run_rebase failure -i
219 +test_run_rebase failure -p
220 +
221 test_done