Skip to content

Commit c282eba

Browse files
zivarahgitster
authored andcommitted
rebase: update --empty=ask to --empty=stop
When git-am(1) got its own `--empty` option in 7c096b8 (am: support --empty=<option> to handle empty patches, 2021-12-09), `stop` was used instead of `ask`. `stop` is a more accurate term for describing what really happens, and consistency is good. Update git-rebase(1) to also use `stop`, while keeping `ask` as a deprecated synonym. Update the tests to primarily use `stop`, but also ensure that `ask` is still allowed. In a future commit, we'll be adding a new `--empty` option for git-cherry-pick(1) as well, making the consistency even more relevant. Reported-by: Elijah Newren <[email protected]> Signed-off-by: Brian Lyles <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64a443e commit c282eba

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

Documentation/git-rebase.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,23 +289,24 @@ See also INCOMPATIBLE OPTIONS below.
289289
+
290290
See also INCOMPATIBLE OPTIONS below.
291291

292-
--empty=(ask|drop|keep)::
292+
--empty=(drop|keep|stop)::
293293
How to handle commits that are not empty to start and are not
294294
clean cherry-picks of any upstream commit, but which become
295295
empty after rebasing (because they contain a subset of already
296296
upstream changes):
297297
+
298298
--
299-
`ask`;;
300-
The rebase will halt when the commit is applied, allowing you to
301-
choose whether to drop it, edit files more, or just commit the empty
302-
changes. This option is implied when `-i`/`--interactive` is
303-
specified.
304299
`drop`;;
305300
The commit will be dropped. This is the default behavior.
306301
`keep`;;
307302
The commit will be kept. This option is implied when `--exec` is
308303
specified unless `-i`/`--interactive` is also specified.
304+
`stop`;;
305+
`ask`;;
306+
The rebase will halt when the commit is applied, allowing you to
307+
choose whether to drop it, edit files more, or just commit the empty
308+
changes. This option is implied when `-i`/`--interactive` is
309+
specified. `ask` is a deprecated synonym of `stop`.
309310
--
310311
+
311312
Note that commits which start empty are kept (unless `--no-keep-empty`
@@ -711,7 +712,7 @@ be dropped automatically with `--no-keep-empty`).
711712
Similar to the apply backend, by default the merge backend drops
712713
commits that become empty unless `-i`/`--interactive` is specified (in
713714
which case it stops and asks the user what to do). The merge backend
714-
also has an `--empty=(ask|drop|keep)` option for changing the behavior
715+
also has an `--empty=(drop|keep|stop)` option for changing the behavior
715716
of handling commits that become empty.
716717

717718
Directory rename detection

builtin/rebase.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum empty_type {
5858
EMPTY_UNSPECIFIED = -1,
5959
EMPTY_DROP,
6060
EMPTY_KEEP,
61-
EMPTY_ASK
61+
EMPTY_STOP
6262
};
6363

6464
enum action {
@@ -951,10 +951,14 @@ static enum empty_type parse_empty_value(const char *value)
951951
return EMPTY_DROP;
952952
else if (!strcasecmp(value, "keep"))
953953
return EMPTY_KEEP;
954-
else if (!strcasecmp(value, "ask"))
955-
return EMPTY_ASK;
954+
else if (!strcasecmp(value, "stop"))
955+
return EMPTY_STOP;
956+
else if (!strcasecmp(value, "ask")) {
957+
warning(_("--empty=ask is deprecated; use '--empty=stop' instead."));
958+
return EMPTY_STOP;
959+
}
956960

957-
die(_("unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and \"ask\"."), value);
961+
die(_("unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and \"stop\"."), value);
958962
}
959963

960964
static int parse_opt_keep_empty(const struct option *opt, const char *arg,
@@ -1133,7 +1137,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
11331137
"instead of ignoring them"),
11341138
1, PARSE_OPT_HIDDEN),
11351139
OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
1136-
OPT_CALLBACK_F(0, "empty", &options, "(drop|keep|ask)",
1140+
OPT_CALLBACK_F(0, "empty", &options, "(drop|keep|stop)",
11371141
N_("how to handle commits that become empty"),
11381142
PARSE_OPT_NONEG, parse_opt_empty),
11391143
OPT_CALLBACK_F('k', "keep-empty", &options, NULL,
@@ -1550,7 +1554,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15501554

15511555
if (options.empty == EMPTY_UNSPECIFIED) {
15521556
if (options.flags & REBASE_INTERACTIVE_EXPLICIT)
1553-
options.empty = EMPTY_ASK;
1557+
options.empty = EMPTY_STOP;
15541558
else if (options.exec.nr > 0)
15551559
options.empty = EMPTY_KEEP;
15561560
else

t/t3424-rebase-empty.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ test_expect_success 'rebase --merge --empty=keep' '
7272
test_cmp expect actual
7373
'
7474

75+
test_expect_success 'rebase --merge --empty=stop' '
76+
git checkout -B testing localmods &&
77+
test_must_fail git rebase --merge --empty=stop upstream &&
78+
79+
git rebase --skip &&
80+
81+
test_write_lines D C B A >expect &&
82+
git log --format=%s >actual &&
83+
test_cmp expect actual
84+
'
85+
7586
test_expect_success 'rebase --merge --empty=ask' '
7687
git checkout -B testing localmods &&
7788
test_must_fail git rebase --merge --empty=ask upstream &&
@@ -101,9 +112,9 @@ test_expect_success 'rebase --interactive --empty=keep' '
101112
test_cmp expect actual
102113
'
103114

104-
test_expect_success 'rebase --interactive --empty=ask' '
115+
test_expect_success 'rebase --interactive --empty=stop' '
105116
git checkout -B testing localmods &&
106-
test_must_fail git rebase --interactive --empty=ask upstream &&
117+
test_must_fail git rebase --interactive --empty=stop upstream &&
107118
108119
git rebase --skip &&
109120
@@ -112,7 +123,7 @@ test_expect_success 'rebase --interactive --empty=ask' '
112123
test_cmp expect actual
113124
'
114125

115-
test_expect_success 'rebase --interactive uses default of --empty=ask' '
126+
test_expect_success 'rebase --interactive uses default of --empty=stop' '
116127
git checkout -B testing localmods &&
117128
test_must_fail git rebase --interactive upstream &&
118129
@@ -194,9 +205,9 @@ test_expect_success 'rebase --exec uses default of --empty=keep' '
194205
test_cmp expect actual
195206
'
196207

197-
test_expect_success 'rebase --exec --empty=ask' '
208+
test_expect_success 'rebase --exec --empty=stop' '
198209
git checkout -B testing localmods &&
199-
test_must_fail git rebase --exec "true" --empty=ask upstream &&
210+
test_must_fail git rebase --exec "true" --empty=stop upstream &&
200211
201212
git rebase --skip &&
202213

0 commit comments

Comments
 (0)