Merge branch 'rj/add-i-leak-fix'
[git.git] / t / t3424-rebase-empty.sh
blob1ee6b00fd57726e055b95903e09f97c1e24ebcd2
1 #!/bin/sh
3 test_description='git rebase of commits that start or become empty'
5 . ./test-lib.sh
7 test_expect_success 'setup test repository' '
8 test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers &&
9 test_write_lines A B C D E F G H I J >letters &&
10 git add numbers letters &&
11 git commit -m A &&
13 git branch upstream &&
14 git branch localmods &&
16 git checkout upstream &&
17 test_write_lines A B C D E >letters &&
18 git add letters &&
19 git commit -m B &&
21 test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers &&
22 git add numbers &&
23 git commit -m C &&
25 git checkout localmods &&
26 test_write_lines 1 2 3 4 five 6 7 8 9 10 >numbers &&
27 git add numbers &&
28 git commit -m C2 &&
30 git commit --allow-empty -m D &&
32 test_write_lines A B C D E >letters &&
33 git add letters &&
34 git commit -m "Five letters ought to be enough for anybody"
37 test_expect_failure 'rebase (apply-backend)' '
38 test_when_finished "git rebase --abort" &&
39 git checkout -B testing localmods &&
40 # rebase (--apply) should not drop commits that start empty
41 git rebase --apply upstream &&
43 test_write_lines D C B A >expect &&
44 git log --format=%s >actual &&
45 test_cmp expect actual
48 test_expect_success 'rebase --merge --empty=drop' '
49 git checkout -B testing localmods &&
50 git rebase --merge --empty=drop upstream &&
52 test_write_lines D C B A >expect &&
53 git log --format=%s >actual &&
54 test_cmp expect actual
57 test_expect_success 'rebase --merge uses default of --empty=drop' '
58 git checkout -B testing localmods &&
59 git rebase --merge upstream &&
61 test_write_lines D C B A >expect &&
62 git log --format=%s >actual &&
63 test_cmp expect actual
66 test_expect_success 'rebase --merge --empty=keep' '
67 git checkout -B testing localmods &&
68 git rebase --merge --empty=keep upstream &&
70 test_write_lines D C2 C B A >expect &&
71 git log --format=%s >actual &&
72 test_cmp expect actual
75 test_expect_success 'rebase --merge --empty=stop' '
76 git checkout -B testing localmods &&
77 test_must_fail git rebase --merge --empty=stop upstream &&
79 git rebase --skip &&
81 test_write_lines D C B A >expect &&
82 git log --format=%s >actual &&
83 test_cmp expect actual
86 test_expect_success 'rebase --merge --empty=ask' '
87 git checkout -B testing localmods &&
88 test_must_fail git rebase --merge --empty=ask upstream &&
90 git rebase --skip &&
92 test_write_lines D C B A >expect &&
93 git log --format=%s >actual &&
94 test_cmp expect actual
97 test_expect_success 'rebase --interactive --empty=drop' '
98 git checkout -B testing localmods &&
99 git rebase --interactive --empty=drop upstream &&
101 test_write_lines D C B A >expect &&
102 git log --format=%s >actual &&
103 test_cmp expect actual
106 test_expect_success 'rebase --interactive --empty=keep' '
107 git checkout -B testing localmods &&
108 git rebase --interactive --empty=keep upstream &&
110 test_write_lines D C2 C B A >expect &&
111 git log --format=%s >actual &&
112 test_cmp expect actual
115 test_expect_success 'rebase --interactive --empty=stop' '
116 git checkout -B testing localmods &&
117 test_must_fail git rebase --interactive --empty=stop upstream &&
119 git rebase --skip &&
121 test_write_lines D C B A >expect &&
122 git log --format=%s >actual &&
123 test_cmp expect actual
126 test_expect_success 'rebase --interactive uses default of --empty=stop' '
127 git checkout -B testing localmods &&
128 test_must_fail git rebase --interactive upstream &&
130 git rebase --skip &&
132 test_write_lines D C B A >expect &&
133 git log --format=%s >actual &&
134 test_cmp expect actual
137 test_expect_success 'rebase --merge --empty=drop --keep-empty' '
138 git checkout -B testing localmods &&
139 git rebase --merge --empty=drop --keep-empty upstream &&
141 test_write_lines D C B A >expect &&
142 git log --format=%s >actual &&
143 test_cmp expect actual
146 test_expect_success 'rebase --merge --empty=drop --no-keep-empty' '
147 git checkout -B testing localmods &&
148 git rebase --merge --empty=drop --no-keep-empty upstream &&
150 test_write_lines C B A >expect &&
151 git log --format=%s >actual &&
152 test_cmp expect actual
155 test_expect_success 'rebase --merge --empty=keep --keep-empty' '
156 git checkout -B testing localmods &&
157 git rebase --merge --empty=keep --keep-empty upstream &&
159 test_write_lines D C2 C B A >expect &&
160 git log --format=%s >actual &&
161 test_cmp expect actual
164 test_expect_success 'rebase --merge --empty=keep --no-keep-empty' '
165 git checkout -B testing localmods &&
166 git rebase --merge --empty=keep --no-keep-empty upstream &&
168 test_write_lines C2 C B A >expect &&
169 git log --format=%s >actual &&
170 test_cmp expect actual
173 test_expect_success 'rebase --merge does not leave state laying around' '
174 git checkout -B testing localmods~2 &&
175 git rebase --merge upstream &&
177 test_path_is_missing .git/CHERRY_PICK_HEAD &&
178 test_path_is_missing .git/MERGE_MSG
181 test_expect_success 'rebase --exec --empty=drop' '
182 git checkout -B testing localmods &&
183 git rebase --exec "true" --empty=drop upstream &&
185 test_write_lines D C B A >expect &&
186 git log --format=%s >actual &&
187 test_cmp expect actual
190 test_expect_success 'rebase --exec --empty=keep' '
191 git checkout -B testing localmods &&
192 git rebase --exec "true" --empty=keep upstream &&
194 test_write_lines D C2 C B A >expect &&
195 git log --format=%s >actual &&
196 test_cmp expect actual
199 test_expect_success 'rebase --exec uses default of --empty=keep' '
200 git checkout -B testing localmods &&
201 git rebase --exec "true" upstream &&
203 test_write_lines D C2 C B A >expect &&
204 git log --format=%s >actual &&
205 test_cmp expect actual
208 test_expect_success 'rebase --exec --empty=stop' '
209 git checkout -B testing localmods &&
210 test_must_fail git rebase --exec "true" --empty=stop upstream &&
212 git rebase --skip &&
214 test_write_lines D C B A >expect &&
215 git log --format=%s >actual &&
216 test_cmp expect actual
219 test_done