]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3431-rebase-fork-point.sh
Merge branch 'ab/detox-gettext-tests'
[thirdparty/git.git] / t / t3431-rebase-fork-point.sh
CommitLineData
359ecebc
DL
1#!/bin/sh
2#
3# Copyright (c) 2019 Denton Liu
4#
5
6test_description='git rebase --fork-point test'
7
d1c02d93 8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
359ecebc
DL
11. ./test-lib.sh
12
d1c02d93 13# A---B---D---E (main)
359ecebc
DL
14# \
15# C*---F---G (side)
16#
d1c02d93 17# C was formerly part of main but main was rewound to remove C
359ecebc
DL
18#
19test_expect_success setup '
20 test_commit A &&
21 test_commit B &&
22 test_commit C &&
23 git branch -t side &&
24 git reset --hard HEAD^ &&
25 test_commit D &&
26 test_commit E &&
27 git checkout side &&
28 test_commit F &&
29 test_commit G
30'
31
32test_rebase () {
33 expected="$1" &&
34 shift &&
35 test_expect_success "git rebase $*" "
d1c02d93 36 git checkout main &&
359ecebc
DL
37 git reset --hard E &&
38 git checkout side &&
39 git reset --hard G &&
40 git rebase $* &&
41 test_write_lines $expected >expect &&
42 git log --pretty=%s >actual &&
43 test_cmp expect actual
44 "
45}
46
47test_rebase 'G F E D B A'
48test_rebase 'G F D B A' --onto D
414d924b 49test_rebase 'G F B A' --keep-base
359ecebc
DL
50test_rebase 'G F C E D B A' --no-fork-point
51test_rebase 'G F C D B A' --no-fork-point --onto D
414d924b 52test_rebase 'G F C B A' --no-fork-point --keep-base
f08132f8 53
d1c02d93
JS
54test_rebase 'G F E D B A' --fork-point refs/heads/main
55test_rebase 'G F E D B A' --fork-point main
f08132f8 56
d1c02d93
JS
57test_rebase 'G F D B A' --fork-point --onto D refs/heads/main
58test_rebase 'G F D B A' --fork-point --onto D main
f08132f8 59
d1c02d93
JS
60test_rebase 'G F B A' --fork-point --keep-base refs/heads/main
61test_rebase 'G F B A' --fork-point --keep-base main
f08132f8 62
d1c02d93
JS
63test_rebase 'G F C E D B A' refs/heads/main
64test_rebase 'G F C E D B A' main
f08132f8 65
d1c02d93
JS
66test_rebase 'G F C D B A' --onto D refs/heads/main
67test_rebase 'G F C D B A' --onto D main
f08132f8 68
d1c02d93
JS
69test_rebase 'G F C B A' --keep-base refs/heads/main
70test_rebase 'G F C B A' --keep-base main
f08132f8
JH
71
72test_expect_success 'git rebase --fork-point with ambigous refname' '
d1c02d93 73 git checkout main &&
f08132f8
JH
74 git checkout -b one &&
75 git checkout side &&
76 git tag one &&
77 test_must_fail git rebase --fork-point --onto D one
78'
359ecebc
DL
79
80test_done