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^ &&
40 test_write_lines
$expected >expect
&&
41 git log
--pretty=%s
>actual
&&
42 test_cmp expect actual
48 test_expect_success
"git rebase $*" "do_test_rebase '$expected' $*"
51 test_rebase
'G F E D B A'
52 test_rebase
'G F D B A' --onto D
53 test_rebase
'G F B A' --keep-base
54 test_rebase
'G F C E D B A' --no-fork-point
55 test_rebase
'G F C D B A' --no-fork-point --onto D
56 test_rebase
'G F C B A' --no-fork-point --keep-base
58 test_rebase
'G F E D B A' --fork-point refs
/heads
/main
59 test_rebase
'G F E D B A' --fork-point main
61 test_rebase
'G F D B A' --fork-point --onto D refs
/heads
/main
62 test_rebase
'G F D B A' --fork-point --onto D main
64 test_rebase
'G F B A' --fork-point --keep-base refs
/heads
/main
65 test_rebase
'G F B A' --fork-point --keep-base main
67 test_rebase
'G F C E D B A' refs
/heads
/main
68 test_rebase
'G F C E D B A' main
70 test_rebase
'G F C D B A' --onto D refs
/heads
/main
71 test_rebase
'G F C D B A' --onto D main
73 test_rebase
'G F C B A' --keep-base refs
/heads
/main
74 test_rebase
'G F C B A' --keep-base main
76 test_expect_success
'git rebase --fork-point with ambigous refname' '
78 git checkout -b one &&
81 test_must_fail git rebase --fork-point --onto D one
84 test_expect_success
'--fork-point and --root both given' '
85 test_must_fail git rebase --fork-point --root 2>err &&
86 test_i18ngrep "cannot be used together" err
89 test_expect_success
'rebase.forkPoint set to false' '
90 test_config rebase.forkPoint false &&
91 do_test_rebase "G F C E D B A"
94 test_expect_success
'rebase.forkPoint set to false and then to true' '
95 test_config_global rebase.forkPoint false &&
96 test_config rebase.forkPoint true &&
97 do_test_rebase "G F E D B A"
100 test_expect_success
'rebase.forkPoint set to false and command line says --fork-point' '
101 test_config rebase.forkPoint false &&
102 do_test_rebase "G F E D B A" --fork-point
105 test_expect_success
'rebase.forkPoint set to true and command line says --no-fork-point' '
106 test_config rebase.forkPoint true &&
107 do_test_rebase "G F C E D B A" --no-fork-point
110 test_expect_success
'rebase.forkPoint set to true and --root given' '
111 test_config rebase.forkPoint true &&