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
11 TEST_PASSES_SANITIZE_LEAK
=true
14 # A---B---D---E (main)
18 # C was formerly part of main but main was rewound to remove C
20 test_expect_success setup
'
25 git reset --hard HEAD^ &&
41 test_write_lines
$expected >expect
&&
42 git log
--pretty=%s
>actual
&&
43 test_cmp expect actual
49 test_expect_success
"git rebase $*" "do_test_rebase '$expected' $*"
52 test_rebase
'G F E D B A'
53 test_rebase
'G F D B A' --onto D
54 test_rebase
'G F C B A' --keep-base
55 test_rebase
'G F C E D B A' --no-fork-point
56 test_rebase
'G F C D B A' --no-fork-point --onto D
57 test_rebase
'G F C B A' --no-fork-point --keep-base
59 test_rebase
'G F E D B A' --fork-point refs
/heads
/main
60 test_rebase
'G F E D B A' --fork-point main
62 test_rebase
'G F D B A' --fork-point --onto D refs
/heads
/main
63 test_rebase
'G F D B A' --fork-point --onto D main
65 test_rebase
'G F B A' --fork-point --keep-base refs
/heads
/main
66 test_rebase
'G F B A' --fork-point --keep-base main
68 test_rebase
'G F C E D B A' refs
/heads
/main
69 test_rebase
'G F C E D B A' main
71 test_rebase
'G F C D B A' --onto D refs
/heads
/main
72 test_rebase
'G F C D B A' --onto D main
74 test_rebase
'G F C B A' --keep-base refs
/heads
/main
75 test_rebase
'G F C B A' --keep-base main
77 test_expect_success
'git rebase --fork-point with ambigous refname' '
79 git checkout -b one &&
82 test_must_fail git rebase --fork-point --onto D one
85 test_expect_success
'--fork-point and --root both given' '
86 test_must_fail git rebase --fork-point --root 2>err &&
87 test_i18ngrep "cannot be used together" err
90 test_expect_success
'rebase.forkPoint set to false' '
91 test_config rebase.forkPoint false &&
92 do_test_rebase "G F C E D B A"
95 test_expect_success
'rebase.forkPoint set to false and then to true' '
96 test_config_global rebase.forkPoint false &&
97 test_config rebase.forkPoint true &&
98 do_test_rebase "G F E D B A"
101 test_expect_success
'rebase.forkPoint set to false and command line says --fork-point' '
102 test_config rebase.forkPoint false &&
103 do_test_rebase "G F E D B A" --fork-point
106 test_expect_success
'rebase.forkPoint set to true and command line says --no-fork-point' '
107 test_config rebase.forkPoint true &&
108 do_test_rebase "G F C E D B A" --no-fork-point
111 test_expect_success
'rebase.forkPoint set to true and --root given' '
112 test_config rebase.forkPoint true &&