2018-06-27 09:23:13 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='test if rebase detects and aborts on incompatible options'
|
2021-11-16 19:27:38 +01:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2018-06-27 09:23:13 +02: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 05:03:45 +01: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 09:23:13 +02: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 09:23:14 +02:00
|
|
|
test_expect_success "$opt incompatible with --merge" "
|
2018-06-27 09:23:13 +02: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 09:23:14 +02:00
|
|
|
test_expect_success "$opt incompatible with --strategy=ours" "
|
2018-06-27 09:23:13 +02: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 09:23:14 +02:00
|
|
|
test_expect_success "$opt incompatible with --strategy-option=ours" "
|
2018-06-27 09:23:13 +02:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --strategy-option=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 09:23:14 +02:00
|
|
|
test_expect_success "$opt incompatible with --interactive" "
|
2018-06-27 09:23:13 +02: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 09:23:14 +02:00
|
|
|
test_expect_success "$opt incompatible with --exec" "
|
2018-06-27 09:23:13 +02:00
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --exec 'true' A
|
|
|
|
"
|
|
|
|
|
2023-01-25 05:03:45 +01: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 05:03:48 +01:00
|
|
|
test_expect_success "$opt incompatible with --root without --onto" "
|
|
|
|
git checkout B^0 &&
|
|
|
|
test_must_fail git rebase $opt --root A
|
|
|
|
"
|
2018-06-27 09:23:13 +02:00
|
|
|
}
|
|
|
|
|
2023-01-25 05:03:46 +01:00
|
|
|
# Check options which imply --apply
|
2018-06-27 09:23:13 +02:00
|
|
|
test_rebase_am_only --whitespace=fix
|
|
|
|
test_rebase_am_only -C4
|
2023-01-25 05:03:46 +01:00
|
|
|
# Also check an explicit --apply
|
|
|
|
test_rebase_am_only --apply
|
2018-06-27 09:23:13 +02:00
|
|
|
|
|
|
|
test_done
|