3 # Copyright (c) 2019 Denton Liu
6 test_description='git rebase --fork-point test'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13 # A---B---D---E (main)
17 # C was formerly part of main but main was rewound to remove C
19 test_expect_success setup '
24 git reset --hard HEAD^ &&
35 test_expect_success "git rebase $*" "
41 test_write_lines $expected >expect &&
42 git log --pretty=%s >actual &&
43 test_cmp expect actual
47 test_rebase 'G F E D B A'
48 test_rebase 'G F D B A' --onto D
49 test_rebase 'G F B A' --keep-base
50 test_rebase 'G F C E D B A' --no-fork-point
51 test_rebase 'G F C D B A' --no-fork-point --onto D
52 test_rebase 'G F C B A' --no-fork-point --keep-base
54 test_rebase 'G F E D B A' --fork-point refs/heads/main
55 test_rebase 'G F E D B A' --fork-point main
57 test_rebase 'G F D B A' --fork-point --onto D refs/heads/main
58 test_rebase 'G F D B A' --fork-point --onto D main
60 test_rebase 'G F B A' --fork-point --keep-base refs/heads/main
61 test_rebase 'G F B A' --fork-point --keep-base main
63 test_rebase 'G F C E D B A' refs/heads/main
64 test_rebase 'G F C E D B A' main
66 test_rebase 'G F C D B A' --onto D refs/heads/main
67 test_rebase 'G F C D B A' --onto D main
69 test_rebase 'G F C B A' --keep-base refs/heads/main
70 test_rebase 'G F C B A' --keep-base main
72 test_expect_success 'git rebase --fork-point with ambigous refname' '
74 git checkout -b one &&
77 test_must_fail git rebase --fork-point --onto D one