3 test_description
='git rebase of commits that start or become empty'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup test repository' '
9 test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers &&
10 test_write_lines A B C D E F G H I J >letters &&
11 git add numbers letters &&
14 git branch upstream &&
15 git branch localmods &&
17 git checkout upstream &&
18 test_write_lines A B C D E >letters &&
22 test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers &&
26 git checkout localmods &&
27 test_write_lines 1 2 3 4 five 6 7 8 9 10 >numbers &&
31 git commit --allow-empty -m D &&
33 test_write_lines A B C D E >letters &&
35 git commit -m "Five letters ought to be enough for anybody"
38 test_expect_failure
'rebase (apply-backend)' '
39 test_when_finished "git rebase --abort" &&
40 git checkout -B testing localmods &&
41 # rebase (--apply) should not drop commits that start empty
42 git rebase --apply upstream &&
44 test_write_lines D C B A >expect &&
45 git log --format=%s >actual &&
46 test_cmp expect actual
49 test_expect_success
'rebase --merge --empty=drop' '
50 git checkout -B testing localmods &&
51 git rebase --merge --empty=drop upstream &&
53 test_write_lines D C B A >expect &&
54 git log --format=%s >actual &&
55 test_cmp expect actual
58 test_expect_success
'rebase --merge uses default of --empty=drop' '
59 git checkout -B testing localmods &&
60 git rebase --merge upstream &&
62 test_write_lines D C B A >expect &&
63 git log --format=%s >actual &&
64 test_cmp expect actual
67 test_expect_success
'rebase --merge --empty=keep' '
68 git checkout -B testing localmods &&
69 git rebase --merge --empty=keep upstream &&
71 test_write_lines D C2 C B A >expect &&
72 git log --format=%s >actual &&
73 test_cmp expect actual
76 test_expect_success
'rebase --merge --empty=stop' '
77 git checkout -B testing localmods &&
78 test_must_fail git rebase --merge --empty=stop upstream &&
82 test_write_lines D C B A >expect &&
83 git log --format=%s >actual &&
84 test_cmp expect actual
87 test_expect_success
'rebase --merge --empty=ask' '
88 git checkout -B testing localmods &&
89 test_must_fail git rebase --merge --empty=ask upstream &&
93 test_write_lines D C B A >expect &&
94 git log --format=%s >actual &&
95 test_cmp expect actual
98 test_expect_success
'rebase --interactive --empty=drop' '
99 git checkout -B testing localmods &&
100 git rebase --interactive --empty=drop upstream &&
102 test_write_lines D C B A >expect &&
103 git log --format=%s >actual &&
104 test_cmp expect actual
107 test_expect_success
'rebase --interactive --empty=keep' '
108 git checkout -B testing localmods &&
109 git rebase --interactive --empty=keep upstream &&
111 test_write_lines D C2 C B A >expect &&
112 git log --format=%s >actual &&
113 test_cmp expect actual
116 test_expect_success
'rebase --interactive --empty=stop' '
117 git checkout -B testing localmods &&
118 test_must_fail git rebase --interactive --empty=stop upstream &&
122 test_write_lines D C B A >expect &&
123 git log --format=%s >actual &&
124 test_cmp expect actual
127 test_expect_success
'rebase --interactive uses default of --empty=stop' '
128 git checkout -B testing localmods &&
129 test_must_fail git rebase --interactive upstream &&
133 test_write_lines D C B A >expect &&
134 git log --format=%s >actual &&
135 test_cmp expect actual
138 test_expect_success
'rebase --merge --empty=drop --keep-empty' '
139 git checkout -B testing localmods &&
140 git rebase --merge --empty=drop --keep-empty upstream &&
142 test_write_lines D C B A >expect &&
143 git log --format=%s >actual &&
144 test_cmp expect actual
147 test_expect_success
'rebase --merge --empty=drop --no-keep-empty' '
148 git checkout -B testing localmods &&
149 git rebase --merge --empty=drop --no-keep-empty upstream &&
151 test_write_lines C B A >expect &&
152 git log --format=%s >actual &&
153 test_cmp expect actual
156 test_expect_success
'rebase --merge --empty=keep --keep-empty' '
157 git checkout -B testing localmods &&
158 git rebase --merge --empty=keep --keep-empty upstream &&
160 test_write_lines D C2 C B A >expect &&
161 git log --format=%s >actual &&
162 test_cmp expect actual
165 test_expect_success
'rebase --merge --empty=keep --no-keep-empty' '
166 git checkout -B testing localmods &&
167 git rebase --merge --empty=keep --no-keep-empty upstream &&
169 test_write_lines C2 C B A >expect &&
170 git log --format=%s >actual &&
171 test_cmp expect actual
174 test_expect_success
'rebase --merge does not leave state laying around' '
175 git checkout -B testing localmods~2 &&
176 git rebase --merge upstream &&
178 test_path_is_missing .git/CHERRY_PICK_HEAD &&
179 test_path_is_missing .git/MERGE_MSG
182 test_expect_success
'rebase --exec --empty=drop' '
183 git checkout -B testing localmods &&
184 git rebase --exec "true" --empty=drop upstream &&
186 test_write_lines D C B A >expect &&
187 git log --format=%s >actual &&
188 test_cmp expect actual
191 test_expect_success
'rebase --exec --empty=keep' '
192 git checkout -B testing localmods &&
193 git rebase --exec "true" --empty=keep upstream &&
195 test_write_lines D C2 C B A >expect &&
196 git log --format=%s >actual &&
197 test_cmp expect actual
200 test_expect_success
'rebase --exec uses default of --empty=keep' '
201 git checkout -B testing localmods &&
202 git rebase --exec "true" upstream &&
204 test_write_lines D C2 C B A >expect &&
205 git log --format=%s >actual &&
206 test_cmp expect actual
209 test_expect_success
'rebase --exec --empty=stop' '
210 git checkout -B testing localmods &&
211 test_must_fail git rebase --exec "true" --empty=stop upstream &&
215 test_write_lines D C B A >expect &&
216 git log --format=%s >actual &&
217 test_cmp expect actual