2018-06-27 07:23:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test if rebase detects and aborts on incompatible options'
|
2021-11-16 18:27:38 +00:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2018-06-27 07:23:13 +00:00
|
|
|
. ./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
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
2023-01-25 04:03:45 +00:00
|
|
|
# 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.
|
2018-06-27 07:23:13 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
test_rebase_am_only () {
|
|
|
|
opt=$1
|
|
|
|
shift
|
git-rebase: error out when incompatible options passed
git rebase has three different types: am, merge, and interactive, all of
which are implemented in terms of separate scripts. am builds on git-am,
merge builds on git-merge-recursive, and interactive builds on
git-cherry-pick. We make use of features in those lower-level commands in
the different rebase types, but those features don't exist in all of the
lower level commands so we have a range of incompatibilities. Previously,
we just accepted nearly any argument and silently ignored whichever ones
weren't implemented for the type of rebase specified. Change this so the
incompatibilities are documented, included in the testsuite, and tested
for at runtime with an appropriate error message shown.
Some exceptions I left out:
* --merge and --interactive are technically incompatible since they are
supposed to run different underlying scripts, but with a few small
changes, --interactive can do everything that --merge can. In fact,
I'll shortly be sending another patch to remove git-rebase--merge and
reimplement it on top of git-rebase--interactive.
* One could argue that --interactive and --quiet are incompatible since
--interactive doesn't implement a --quiet mode (perhaps since
cherry-pick itself does not implement one). However, the interactive
mode is more quiet than the other modes in general with progress
messages, so one could argue that it's already quiet.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-06-27 07:23:14 +00:00
|
|
|
test_expect_success "$opt incompatible with --merge" "
|
2018-06-27 07:23:13 +00:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --merge A
|
|
|
|
"
|
|
|
|
|
git-rebase: error out when incompatible options passed
git rebase has three different types: am, merge, and interactive, all of
which are implemented in terms of separate scripts. am builds on git-am,
merge builds on git-merge-recursive, and interactive builds on
git-cherry-pick. We make use of features in those lower-level commands in
the different rebase types, but those features don't exist in all of the
lower level commands so we have a range of incompatibilities. Previously,
we just accepted nearly any argument and silently ignored whichever ones
weren't implemented for the type of rebase specified. Change this so the
incompatibilities are documented, included in the testsuite, and tested
for at runtime with an appropriate error message shown.
Some exceptions I left out:
* --merge and --interactive are technically incompatible since they are
supposed to run different underlying scripts, but with a few small
changes, --interactive can do everything that --merge can. In fact,
I'll shortly be sending another patch to remove git-rebase--merge and
reimplement it on top of git-rebase--interactive.
* One could argue that --interactive and --quiet are incompatible since
--interactive doesn't implement a --quiet mode (perhaps since
cherry-pick itself does not implement one). However, the interactive
mode is more quiet than the other modes in general with progress
messages, so one could argue that it's already quiet.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-06-27 07:23:14 +00:00
|
|
|
test_expect_success "$opt incompatible with --strategy=ours" "
|
2018-06-27 07:23:13 +00:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --strategy=ours A
|
|
|
|
"
|
|
|
|
|
git-rebase: error out when incompatible options passed
git rebase has three different types: am, merge, and interactive, all of
which are implemented in terms of separate scripts. am builds on git-am,
merge builds on git-merge-recursive, and interactive builds on
git-cherry-pick. We make use of features in those lower-level commands in
the different rebase types, but those features don't exist in all of the
lower level commands so we have a range of incompatibilities. Previously,
we just accepted nearly any argument and silently ignored whichever ones
weren't implemented for the type of rebase specified. Change this so the
incompatibilities are documented, included in the testsuite, and tested
for at runtime with an appropriate error message shown.
Some exceptions I left out:
* --merge and --interactive are technically incompatible since they are
supposed to run different underlying scripts, but with a few small
changes, --interactive can do everything that --merge can. In fact,
I'll shortly be sending another patch to remove git-rebase--merge and
reimplement it on top of git-rebase--interactive.
* One could argue that --interactive and --quiet are incompatible since
--interactive doesn't implement a --quiet mode (perhaps since
cherry-pick itself does not implement one). However, the interactive
mode is more quiet than the other modes in general with progress
messages, so one could argue that it's already quiet.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-06-27 07:23:14 +00:00
|
|
|
test_expect_success "$opt incompatible with --strategy-option=ours" "
|
2018-06-27 07:23:13 +00:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --strategy-option=ours A
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:50 +00:00
|
|
|
test_expect_success "$opt incompatible with --autosquash" "
|
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --autosquash A
|
|
|
|
"
|
|
|
|
|
git-rebase: error out when incompatible options passed
git rebase has three different types: am, merge, and interactive, all of
which are implemented in terms of separate scripts. am builds on git-am,
merge builds on git-merge-recursive, and interactive builds on
git-cherry-pick. We make use of features in those lower-level commands in
the different rebase types, but those features don't exist in all of the
lower level commands so we have a range of incompatibilities. Previously,
we just accepted nearly any argument and silently ignored whichever ones
weren't implemented for the type of rebase specified. Change this so the
incompatibilities are documented, included in the testsuite, and tested
for at runtime with an appropriate error message shown.
Some exceptions I left out:
* --merge and --interactive are technically incompatible since they are
supposed to run different underlying scripts, but with a few small
changes, --interactive can do everything that --merge can. In fact,
I'll shortly be sending another patch to remove git-rebase--merge and
reimplement it on top of git-rebase--interactive.
* One could argue that --interactive and --quiet are incompatible since
--interactive doesn't implement a --quiet mode (perhaps since
cherry-pick itself does not implement one). However, the interactive
mode is more quiet than the other modes in general with progress
messages, so one could argue that it's already quiet.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-06-27 07:23:14 +00:00
|
|
|
test_expect_success "$opt incompatible with --interactive" "
|
2018-06-27 07:23:13 +00:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --interactive A
|
|
|
|
"
|
|
|
|
|
git-rebase: error out when incompatible options passed
git rebase has three different types: am, merge, and interactive, all of
which are implemented in terms of separate scripts. am builds on git-am,
merge builds on git-merge-recursive, and interactive builds on
git-cherry-pick. We make use of features in those lower-level commands in
the different rebase types, but those features don't exist in all of the
lower level commands so we have a range of incompatibilities. Previously,
we just accepted nearly any argument and silently ignored whichever ones
weren't implemented for the type of rebase specified. Change this so the
incompatibilities are documented, included in the testsuite, and tested
for at runtime with an appropriate error message shown.
Some exceptions I left out:
* --merge and --interactive are technically incompatible since they are
supposed to run different underlying scripts, but with a few small
changes, --interactive can do everything that --merge can. In fact,
I'll shortly be sending another patch to remove git-rebase--merge and
reimplement it on top of git-rebase--interactive.
* One could argue that --interactive and --quiet are incompatible since
--interactive doesn't implement a --quiet mode (perhaps since
cherry-pick itself does not implement one). However, the interactive
mode is more quiet than the other modes in general with progress
messages, so one could argue that it's already quiet.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-06-27 07:23:14 +00:00
|
|
|
test_expect_success "$opt incompatible with --exec" "
|
2018-06-27 07:23:13 +00:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --exec 'true' A
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:50 +00:00
|
|
|
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
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:49 +00:00
|
|
|
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
|
|
|
|
"
|
|
|
|
|
2023-03-26 03:06:36 +00:00
|
|
|
test_expect_success "$opt incompatible with --rebase-merges" "
|
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --rebase-merges A
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:45 +00:00
|
|
|
test_expect_success "$opt incompatible with --update-refs" "
|
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --update-refs A
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:48 +00:00
|
|
|
test_expect_success "$opt incompatible with --root without --onto" "
|
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --root A
|
|
|
|
"
|
2023-01-25 04:03:54 +00:00
|
|
|
|
2023-03-26 03:06:36 +00:00
|
|
|
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
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:54 +00:00
|
|
|
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
|
|
|
|
"
|
|
|
|
|
2023-03-26 03:06:36 +00:00
|
|
|
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
|
|
|
|
"
|
|
|
|
|
2023-01-25 04:03:54 +00:00
|
|
|
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
|
|
|
|
"
|
2018-06-27 07:23:13 +00:00
|
|
|
}
|
|
|
|
|
2023-01-25 04:03:46 +00:00
|
|
|
# Check options which imply --apply
|
2018-06-27 07:23:13 +00:00
|
|
|
test_rebase_am_only --whitespace=fix
|
|
|
|
test_rebase_am_only -C4
|
2023-01-25 04:03:46 +00:00
|
|
|
# Also check an explicit --apply
|
|
|
|
test_rebase_am_only --apply
|
2018-06-27 07:23:13 +00:00
|
|
|
|
|
|
|
test_done
|