Skip to content

Commit 6a6bc5b

Browse files
martinvonzgitster
authored andcommitted
add tests for rebasing root
Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00b8be5 commit 6a6bc5b

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

t/t3421-rebase-topology-linear.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,133 @@ test_run_rebase failure -m
218218
test_run_rebase failure -i
219219
test_run_rebase failure -p
220220

221+
# m
222+
# /
223+
# a---b---c---g
224+
#
225+
# x---y---B
226+
#
227+
# uppercase = cherry-picked
228+
# m = reverted b
229+
#
230+
# Reverted patches are there for tests to be able to check if a commit
231+
# that introduced the same change as another commit is
232+
# dropped. Without reverted commits, we could get false positives
233+
# because applying the patch succeeds, but simply results in no
234+
# changes.
235+
test_expect_success 'setup of linear history for test involving root' '
236+
git checkout b &&
237+
revert m b &&
238+
git checkout --orphan disjoint &&
239+
git rm -rf . &&
240+
test_commit x &&
241+
test_commit y &&
242+
cherry_pick B b
243+
'
244+
245+
test_run_rebase () {
246+
result=$1
247+
shift
248+
test_expect_$result "rebase $* --onto --root" "
249+
reset_rebase &&
250+
git rebase $* --onto c --root y &&
251+
test_cmp_rev c HEAD~2 &&
252+
test_linear_range 'x y' c..
253+
"
254+
}
255+
test_run_rebase success ''
256+
test_run_rebase failure -m
257+
test_run_rebase success -i
258+
test_run_rebase success -p
259+
260+
test_run_rebase () {
261+
result=$1
262+
shift
263+
test_expect_$result "rebase $* without --onto --root with disjoint history" "
264+
reset_rebase &&
265+
git rebase $* c y &&
266+
test_cmp_rev c HEAD~2 &&
267+
test_linear_range 'x y' c..
268+
"
269+
}
270+
test_run_rebase success ''
271+
test_run_rebase failure -m
272+
test_run_rebase success -i
273+
test_run_rebase failure -p
274+
275+
test_run_rebase () {
276+
result=$1
277+
shift
278+
test_expect_$result "rebase $* --onto --root drops patch in onto" "
279+
reset_rebase &&
280+
git rebase $* --onto m --root B &&
281+
test_cmp_rev m HEAD~2 &&
282+
test_linear_range 'x y' m..
283+
"
284+
}
285+
test_run_rebase success ''
286+
test_run_rebase failure -m
287+
test_run_rebase success -i
288+
test_run_rebase success -p
289+
290+
test_run_rebase () {
291+
result=$1
292+
shift
293+
test_expect_$result "rebase $* --onto --root with merge-base does not go to root" "
294+
reset_rebase &&
295+
git rebase $* --onto m --root g &&
296+
test_cmp_rev m HEAD~2 &&
297+
test_linear_range 'c g' m..
298+
"
299+
}
300+
301+
test_run_rebase success ''
302+
test_run_rebase success -m
303+
test_run_rebase success -i
304+
test_run_rebase failure -p
305+
306+
test_run_rebase () {
307+
result=$1
308+
shift
309+
test_expect_$result "rebase $* without --onto --root with disjoint history drops patch in onto" "
310+
reset_rebase &&
311+
git rebase $* m B &&
312+
test_cmp_rev m HEAD~2 &&
313+
test_linear_range 'x y' m..
314+
"
315+
}
316+
test_run_rebase success ''
317+
test_run_rebase failure -m
318+
test_run_rebase success -i
319+
test_run_rebase failure -p
320+
321+
test_run_rebase () {
322+
result=$1
323+
shift
324+
test_expect_$result "rebase $* --root on linear history is a no-op" "
325+
reset_rebase &&
326+
git rebase $* --root c &&
327+
test_cmp_rev c HEAD
328+
"
329+
}
330+
test_run_rebase failure ''
331+
test_run_rebase failure -m
332+
test_run_rebase failure -i
333+
test_run_rebase failure -p
334+
335+
test_run_rebase () {
336+
result=$1
337+
shift
338+
test_expect_$result "rebase $* -f --root on linear history causes re-write" "
339+
reset_rebase &&
340+
git rebase $* -f --root c &&
341+
! test_cmp_rev a HEAD~2 &&
342+
test_linear_range 'a b c' HEAD
343+
"
344+
}
345+
test_run_rebase success ''
346+
test_run_rebase success -m
347+
test_run_rebase success -i
348+
test_run_rebase success -p
349+
221350
test_done

0 commit comments

Comments
 (0)