Skip to content

Commit 00b8be5

Browse files
martinvonzgitster
authored andcommitted
add tests for rebasing of empty commits
Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b5e1c7 commit 00b8be5

File tree

2 files changed

+58
-24
lines changed

2 files changed

+58
-24
lines changed

t/t3401-rebase-partial.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,4 @@ test_expect_success 'rebase --merge topic branch that was partially merged upstr
4242
test_path_is_missing .git/rebase-merge
4343
'
4444

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-
6945
test_done

t/t3421-rebase-topology-linear.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,62 @@ test_run_rebase success -m
160160
test_run_rebase success -i
161161
test_run_rebase success -p
162162

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+
163221
test_done

0 commit comments

Comments
 (0)