rebase: add a config option for --no-fork-point

Some users (myself included) would prefer to have this feature off by
default because it can silently drop commits.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alex Henrie
2021-02-23 00:18:40 -07:00
committed by Junio C Hamano
parent 66e871b664
commit 2803d800d2
3 changed files with 61 additions and 17 deletions

View File

@ -26,19 +26,23 @@ test_expect_success setup '
test_commit G
'
do_test_rebase () {
expected="$1" &&
shift &&
git checkout master &&
git reset --hard E &&
git checkout side &&
git reset --hard G &&
git rebase $* &&
test_write_lines $expected >expect &&
git log --pretty=%s >actual &&
test_cmp expect actual
}
test_rebase () {
expected="$1" &&
shift &&
test_expect_success "git rebase $*" "
git checkout master &&
git reset --hard E &&
git checkout side &&
git reset --hard G &&
git rebase $* &&
test_write_lines $expected >expect &&
git log --pretty=%s >actual &&
test_cmp expect actual
"
test_expect_success "git rebase $*" "do_test_rebase '$expected' $*"
}
test_rebase 'G F E D B A'
@ -74,4 +78,35 @@ test_expect_success 'git rebase --fork-point with ambigous refname' '
test_must_fail git rebase --fork-point --onto D one
'
test_expect_success '--fork-point and --root both given' '
test_must_fail git rebase --fork-point --root 2>err &&
test_i18ngrep "cannot combine" err
'
test_expect_success 'rebase.forkPoint set to false' '
test_config rebase.forkPoint false &&
do_test_rebase "G F C E D B A"
'
test_expect_success 'rebase.forkPoint set to false and then to true' '
test_config_global rebase.forkPoint false &&
test_config rebase.forkPoint true &&
do_test_rebase "G F E D B A"
'
test_expect_success 'rebase.forkPoint set to false and command line says --fork-point' '
test_config rebase.forkPoint false &&
do_test_rebase "G F E D B A" --fork-point
'
test_expect_success 'rebase.forkPoint set to true and command line says --no-fork-point' '
test_config rebase.forkPoint true &&
do_test_rebase "G F C E D B A" --no-fork-point
'
test_expect_success 'rebase.forkPoint set to true and --root given' '
test_config rebase.forkPoint true &&
git rebase --root
'
test_done