t3422: new testcases for checking when incompatible options passed

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>

Elijah Newren committed Jun 27, 2018 at 00:23 UTC 9929430c32f8754de559e00fba65fd978ecd05da
1 file changed +88
t/t3422-rebase-incompatible-options.sh new
+88
@@ -0,0 +1,88 @@
1 +#!/bin/sh
2 +
3 +test_description='test if rebase detects and aborts on incompatible options'
4 +. ./test-lib.sh
5 +
6 +test_expect_success 'setup' '
7 + test_seq 2 9 >foo &&
8 + git add foo &&
9 + git commit -m orig &&
10 +
11 + git branch A &&
12 + git branch B &&
13 +
14 + git checkout A &&
15 + test_seq 1 9 >foo &&
16 + git add foo &&
17 + git commit -m A &&
18 +
19 + git checkout B &&
20 + echo "q qfoo();" | q_to_tab >>foo &&
21 + git add foo &&
22 + git commit -m B
23 +'
24 +
25 +#
26 +# Rebase has lots of useful options like --whitepsace=fix, which are
27 +# actually all built in terms of flags to git-am. Since neither
28 +# --merge nor --interactive (nor any options that imply those two) use
29 +# git-am, using them together will result in flags like --whitespace=fix
30 +# being ignored. Make sure rebase warns the user and aborts instead.
31 +#
32 +
33 +test_rebase_am_only () {
34 + opt=$1
35 + shift
36 + test_expect_failure "$opt incompatible with --merge" "
37 + git checkout B^0 &&
38 + test_must_fail git rebase $opt --merge A
39 + "
40 +
41 + test_expect_failure "$opt incompatible with --strategy=ours" "
42 + git checkout B^0 &&
43 + test_must_fail git rebase $opt --strategy=ours A
44 + "
45 +
46 + test_expect_failure "$opt incompatible with --strategy-option=ours" "
47 + git checkout B^0 &&
48 + test_must_fail git rebase $opt --strategy-option=ours A
49 + "
50 +
51 + test_expect_failure "$opt incompatible with --interactive" "
52 + git checkout B^0 &&
53 + test_must_fail git rebase $opt --interactive A
54 + "
55 +
56 + test_expect_failure "$opt incompatible with --exec" "
57 + git checkout B^0 &&
58 + test_must_fail git rebase $opt --exec 'true' A
59 + "
60 +
61 +}
62 +
63 +test_rebase_am_only --whitespace=fix
64 +test_rebase_am_only --ignore-whitespace
65 +test_rebase_am_only --committer-date-is-author-date
66 +test_rebase_am_only -C4
67 +
68 +test_expect_success '--preserve-merges incompatible with --signoff' '
69 + git checkout B^0 &&
70 + test_must_fail git rebase --preserve-merges --signoff A
71 +'
72 +
73 +test_expect_failure '--preserve-merges incompatible with --rebase-merges' '
74 + git checkout B^0 &&
75 + test_must_fail git rebase --preserve-merges --rebase-merges A
76 +'
77 +
78 +test_expect_failure '--rebase-merges incompatible with --strategy' '
79 + git checkout B^0 &&
80 + test_must_fail git rebase --rebase-merges -s resolve A
81 +'
82 +
83 +test_expect_failure '--rebase-merges incompatible with --strategy-option' '
84 + git checkout B^0 &&
85 + test_must_fail git rebase --rebase-merges -Xignore-space-change A
86 +'
87 +
88 +test_done