mirror of
https://github.com/git/git.git
synced 2024-12-01 05:54:16 +08:00
75cf39b117
Setting the rebase.autoSquash config variable to true implies a couple of restrictions: it prevents preemptive fast-forwarding and it triggers conflicts with apply backend options. However, it only actually results in auto-squashing when combined with the --interactive (or -i) option, due to code in run_specific_rebase() that disables auto-squashing unless the REBASE_INTERACTIVE_EXPLICIT flag is set. Doing autosquashing for rebase.autoSquash without --interactive would be problematic in terms of backward compatibility, but conversely, there is no need for the aforementioned restrictions without --interactive. So drop the options.config_autosquash check from the conditions for clearing allow_preemptive_ff, as the case where it is combined with --interactive is already covered by the REBASE_INTERACTIVE_EXPLICIT flag check above it. Also drop the "apply options are incompatible with rebase.autoSquash" error, because it is unreachable if it is restricted to --interactive, as apply options already cause an error when used with --interactive. Drop the tests for the error from t3422-rebase-incompatible-options.sh, which has separate tests for the conflicts of --interactive with apply options. When neither --autosquash nor --no-autosquash are given, only set options.autosquash to true if rebase.autosquash is combined with --interactive. Don't initialize options.config_autosquash to -1, as there is no need to distinguish between rebase.autoSquash being unset or explicitly set to false. Finally, amend the rebase.autoSquash documentation to say it only affects interactive mode. Signed-off-by: Andy Koppe <andy.koppe@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
135 lines
3.5 KiB
Bash
Executable File
135 lines
3.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='test if rebase detects and aborts on incompatible options'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_seq 2 9 >foo &&
|
|
git add foo &&
|
|
git commit -m orig &&
|
|
|
|
git branch A &&
|
|
git branch B &&
|
|
|
|
git checkout A &&
|
|
test_seq 1 9 >foo &&
|
|
git add foo &&
|
|
git commit -m A &&
|
|
|
|
git checkout B &&
|
|
echo "q qfoo();" | q_to_tab >>foo &&
|
|
git add foo &&
|
|
git commit -m B
|
|
'
|
|
|
|
#
|
|
# Rebase has a couple options which are specific to the apply backend,
|
|
# and several options which are specific to the merge backend. Flags
|
|
# from the different sets cannot work together, and we do not want to
|
|
# just ignore one of the sets of flags. Make sure rebase warns the
|
|
# user and aborts instead.
|
|
#
|
|
|
|
test_rebase_am_only () {
|
|
opt=$1
|
|
shift
|
|
test_expect_success "$opt incompatible with --merge" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --merge A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --strategy=ours" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --strategy=ours A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --strategy-option=ours" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --strategy-option=ours A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --autosquash" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --autosquash A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --interactive" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --interactive A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --exec" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --exec 'true' A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --keep-empty" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --keep-empty A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --empty=..." "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --empty=ask A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --no-reapply-cherry-picks" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --no-reapply-cherry-picks A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --reapply-cherry-picks" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --reapply-cherry-picks A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --rebase-merges" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --rebase-merges A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --update-refs" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --update-refs A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with --root without --onto" "
|
|
git checkout B^0 &&
|
|
test_must_fail git rebase $opt --root A
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with rebase.rebaseMerges" "
|
|
git checkout B^0 &&
|
|
test_must_fail git -c rebase.rebaseMerges=true rebase $opt A 2>err &&
|
|
grep -e --no-rebase-merges err
|
|
"
|
|
|
|
test_expect_success "$opt incompatible with rebase.updateRefs" "
|
|
git checkout B^0 &&
|
|
test_must_fail git -c rebase.updateRefs=true rebase $opt A 2>err &&
|
|
grep -e --no-update-refs err
|
|
"
|
|
|
|
test_expect_success "$opt okay with overridden rebase.rebaseMerges" "
|
|
test_when_finished \"git reset --hard B^0\" &&
|
|
git checkout B^0 &&
|
|
git -c rebase.rebaseMerges=true rebase --no-rebase-merges $opt A
|
|
"
|
|
|
|
test_expect_success "$opt okay with overridden rebase.updateRefs" "
|
|
test_when_finished \"git reset --hard B^0\" &&
|
|
git checkout B^0 &&
|
|
git -c rebase.updateRefs=true rebase --no-update-refs $opt A
|
|
"
|
|
}
|
|
|
|
# Check options which imply --apply
|
|
test_rebase_am_only --whitespace=fix
|
|
test_rebase_am_only -C4
|
|
# Also check an explicit --apply
|
|
test_rebase_am_only --apply
|
|
|
|
test_done
|