Skip to content

Commit 0af3889

Browse files
zivarahgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Brian Lyles <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e09f125 commit 0af3889

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

Documentation/git-rebase.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ See also INCOMPATIBLE OPTIONS below.
295295
empty after rebasing (because they contain a subset of already
296296
upstream changes). With drop (the default), commits that
297297
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.
303303
+
304304
Note that commits which start empty are kept (unless `--no-keep-empty`
305305
is specified), and commits which are clean cherry-picks (as determined

t/t3424-rebase-empty.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,42 @@ test_expect_success 'rebase --merge does not leave state laying around' '
167167
test_path_is_missing .git/MERGE_MSG
168168
'
169169

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+
170208
test_done

0 commit comments

Comments
 (0)