Skip to content

Commit

Permalink
t3422: new testcases for checking when incompatible options passed
Browse files Browse the repository at this point in the history
git rebase is split into three types: am, merge, and interactive.  Various
options imply different types, and which mode we are using determine which
sub-script (git-rebase--$type) is executed to finish the work.  Not all
options work with all types, so add tests for combinations where we expect
to receive an error rather than having options be silently ignored.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
newren authored and gitster committed Jun 27, 2018
1 parent d4e8062 commit 9929430
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions t/t3422-rebase-incompatible-options.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/sh

test_description='test if rebase detects and aborts on incompatible options'
. ./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 lots of useful options like --whitepsace=fix, which are
# actually all built in terms of flags to git-am. Since neither
# --merge nor --interactive (nor any options that imply those two) use
# git-am, using them together will result in flags like --whitespace=fix
# being ignored. Make sure rebase warns the user and aborts instead.
#

test_rebase_am_only () {
opt=$1
shift
test_expect_failure "$opt incompatible with --merge" "
git checkout B^0 &&
test_must_fail git rebase $opt --merge A
"

test_expect_failure "$opt incompatible with --strategy=ours" "
git checkout B^0 &&
test_must_fail git rebase $opt --strategy=ours A
"

test_expect_failure "$opt incompatible with --strategy-option=ours" "
git checkout B^0 &&
test_must_fail git rebase $opt --strategy-option=ours A
"

test_expect_failure "$opt incompatible with --interactive" "
git checkout B^0 &&
test_must_fail git rebase $opt --interactive A
"

test_expect_failure "$opt incompatible with --exec" "
git checkout B^0 &&
test_must_fail git rebase $opt --exec 'true' A
"

}

test_rebase_am_only --whitespace=fix
test_rebase_am_only --ignore-whitespace
test_rebase_am_only --committer-date-is-author-date
test_rebase_am_only -C4

test_expect_success '--preserve-merges incompatible with --signoff' '
git checkout B^0 &&
test_must_fail git rebase --preserve-merges --signoff A
'

test_expect_failure '--preserve-merges incompatible with --rebase-merges' '
git checkout B^0 &&
test_must_fail git rebase --preserve-merges --rebase-merges A
'

test_expect_failure '--rebase-merges incompatible with --strategy' '
git checkout B^0 &&
test_must_fail git rebase --rebase-merges -s resolve A
'

test_expect_failure '--rebase-merges incompatible with --strategy-option' '
git checkout B^0 &&
test_must_fail git rebase --rebase-merges -Xignore-space-change A
'

test_done

0 comments on commit 9929430

Please sign in to comment.