]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3422-rebase-incompatible-options.sh
The third batch
[thirdparty/git.git] / t / t3422-rebase-incompatible-options.sh
1 #!/bin/sh
2
3 test_description='test if rebase detects and aborts on incompatible options'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'setup' '
9 test_seq 2 9 >foo &&
10 git add foo &&
11 git commit -m orig &&
12
13 git branch A &&
14 git branch B &&
15
16 git checkout A &&
17 test_seq 1 9 >foo &&
18 git add foo &&
19 git commit -m A &&
20
21 git checkout B &&
22 echo "q qfoo();" | q_to_tab >>foo &&
23 git add foo &&
24 git commit -m B
25 '
26
27 #
28 # Rebase has a couple options which are specific to the apply backend,
29 # and several options which are specific to the merge backend. Flags
30 # from the different sets cannot work together, and we do not want to
31 # just ignore one of the sets of flags. Make sure rebase warns the
32 # user and aborts instead.
33 #
34
35 test_rebase_am_only () {
36 opt=$1
37 shift
38 test_expect_success "$opt incompatible with --merge" "
39 git checkout B^0 &&
40 test_must_fail git rebase $opt --merge A
41 "
42
43 test_expect_success "$opt incompatible with --strategy=ours" "
44 git checkout B^0 &&
45 test_must_fail git rebase $opt --strategy=ours A
46 "
47
48 test_expect_success "$opt incompatible with --strategy-option=ours" "
49 git checkout B^0 &&
50 test_must_fail git rebase $opt --strategy-option=ours A
51 "
52
53 test_expect_success "$opt incompatible with --autosquash" "
54 git checkout B^0 &&
55 test_must_fail git rebase $opt --autosquash A
56 "
57
58 test_expect_success "$opt incompatible with --interactive" "
59 git checkout B^0 &&
60 test_must_fail git rebase $opt --interactive A
61 "
62
63 test_expect_success "$opt incompatible with --exec" "
64 git checkout B^0 &&
65 test_must_fail git rebase $opt --exec 'true' A
66 "
67
68 test_expect_success "$opt incompatible with --keep-empty" "
69 git checkout B^0 &&
70 test_must_fail git rebase $opt --keep-empty A
71 "
72
73 test_expect_success "$opt incompatible with --empty=..." "
74 git checkout B^0 &&
75 test_must_fail git rebase $opt --empty=ask A
76 "
77
78 test_expect_success "$opt incompatible with --no-reapply-cherry-picks" "
79 git checkout B^0 &&
80 test_must_fail git rebase $opt --no-reapply-cherry-picks A
81 "
82
83 test_expect_success "$opt incompatible with --reapply-cherry-picks" "
84 git checkout B^0 &&
85 test_must_fail git rebase $opt --reapply-cherry-picks A
86 "
87
88 test_expect_success "$opt incompatible with --rebase-merges" "
89 git checkout B^0 &&
90 test_must_fail git rebase $opt --rebase-merges A
91 "
92
93 test_expect_success "$opt incompatible with --update-refs" "
94 git checkout B^0 &&
95 test_must_fail git rebase $opt --update-refs A
96 "
97
98 test_expect_success "$opt incompatible with --root without --onto" "
99 git checkout B^0 &&
100 test_must_fail git rebase $opt --root A
101 "
102
103 test_expect_success "$opt incompatible with rebase.rebaseMerges" "
104 git checkout B^0 &&
105 test_must_fail git -c rebase.rebaseMerges=true rebase $opt A 2>err &&
106 grep -e --no-rebase-merges err
107 "
108
109 test_expect_success "$opt incompatible with rebase.updateRefs" "
110 git checkout B^0 &&
111 test_must_fail git -c rebase.updateRefs=true rebase $opt A 2>err &&
112 grep -e --no-update-refs err
113 "
114
115 test_expect_success "$opt okay with overridden rebase.rebaseMerges" "
116 test_when_finished \"git reset --hard B^0\" &&
117 git checkout B^0 &&
118 git -c rebase.rebaseMerges=true rebase --no-rebase-merges $opt A
119 "
120
121 test_expect_success "$opt okay with overridden rebase.updateRefs" "
122 test_when_finished \"git reset --hard B^0\" &&
123 git checkout B^0 &&
124 git -c rebase.updateRefs=true rebase --no-update-refs $opt A
125 "
126 }
127
128 # Check options which imply --apply
129 test_rebase_am_only --whitespace=fix
130 test_rebase_am_only -C4
131 # Also check an explicit --apply
132 test_rebase_am_only --apply
133
134 test_done