docs: address inaccurate `--empty` default with `--exec`

The documentation for git-rebase(1) indicates that using the `--exec` option will use `--empty=drop`. This is inaccurate: when `--interactive` is not explicitly provided, `--exec` results in `--empty=keep` behaviors. Correctly indicate the behavior of `--exec` using `--empty=keep` when `--interactive` is not specified. Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Lyles committed Mar 25, 2024 at 18:16 UTC 0af38890ade347536af7690ecee9e5e75d1b2b12
2 files changed +43 -5
Documentation/git-rebase.txt
+5 -5
@@ -295,11 +295,11 @@ See also INCOMPATIBLE OPTIONS below.
295 empty after rebasing (because they contain a subset of already
296 upstream changes). With drop (the default), commits that
297 become empty are dropped. With keep, such commits are kept.
298 - With ask (implied by `--interactive`), the rebase will halt when
299 - an empty commit is applied allowing you to choose whether to
300 - drop it, edit files more, or just commit the empty changes.
301 - Other options, like `--exec`, will use the default of drop unless
302 - `-i`/`--interactive` is explicitly specified.
298 + With ask, the rebase will halt when an empty commit is applied
299 + allowing you to choose whether to drop it, edit files more, or just
300 + commit the empty changes.
301 + When the `-i`/`--interactive` option is used, the default becomes ask.
302 + Otherwise, when the `--exec` option is used, the default becomes keep.
303 +
304 Note that commits which start empty are kept (unless `--no-keep-empty`
305 is specified), and commits which are clean cherry-picks (as determined
t/t3424-rebase-empty.sh
+38
@@ -167,4 +167,42 @@ test_expect_success 'rebase --merge does not leave state laying around' '
167 test_path_is_missing .git/MERGE_MSG
168 '
169
170 +test_expect_success 'rebase --exec --empty=drop' '
171 + git checkout -B testing localmods &&
172 + git rebase --exec "true" --empty=drop upstream &&
173 +
174 + test_write_lines D C B A >expect &&
175 + git log --format=%s >actual &&
176 + test_cmp expect actual
177 +'
178 +
179 +test_expect_success 'rebase --exec --empty=keep' '
180 + git checkout -B testing localmods &&
181 + git rebase --exec "true" --empty=keep upstream &&
182 +
183 + test_write_lines D C2 C B A >expect &&
184 + git log --format=%s >actual &&
185 + test_cmp expect actual
186 +'
187 +
188 +test_expect_success 'rebase --exec uses default of --empty=keep' '
189 + git checkout -B testing localmods &&
190 + git rebase --exec "true" upstream &&
191 +
192 + test_write_lines D C2 C B A >expect &&
193 + git log --format=%s >actual &&
194 + test_cmp expect actual
195 +'
196 +
197 +test_expect_success 'rebase --exec --empty=ask' '
198 + git checkout -B testing localmods &&
199 + test_must_fail git rebase --exec "true" --empty=ask upstream &&
200 +
201 + git rebase --skip &&
202 +
203 + test_write_lines D C B A >expect &&
204 + git log --format=%s >actual &&
205 + test_cmp expect actual
206 +'
207 +
208 test_done