rebase: update `--empty=ask` to `--empty=stop`

When git-am(1) got its own `--empty` option in 7c096b8d61 (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 <newren@gmail.com> 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 c282eba2d561b726e4a60c8837e4eaa2ac6537fa
3 files changed +34 -18
Documentation/git-rebase.txt
+8 -7
@@ -289,23 +289,24 @@ See also INCOMPATIBLE OPTIONS below.
289 +
290 See also INCOMPATIBLE OPTIONS below.
291
292 ---empty=(ask|drop|keep)::
292 +--empty=(drop|keep|stop)::
293 How to handle commits that are not empty to start and are not
294 clean cherry-picks of any upstream commit, but which become
295 empty after rebasing (because they contain a subset of already
296 upstream changes):
297 +
298 --
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.
299 `drop`;;
300 The commit will be dropped. This is the default behavior.
301 `keep`;;
302 The commit will be kept. This option is implied when `--exec` is
303 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`.
310 --
311 +
312 Note that commits which start empty are kept (unless `--no-keep-empty`
@@ -711,7 +712,7 @@ be dropped automatically with `--no-keep-empty`).
712 Similar to the apply backend, by default the merge backend drops
713 commits that become empty unless `-i`/`--interactive` is specified (in
714 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
716 of handling commits that become empty.
717
718 Directory rename detection
builtin/rebase.c
+10 -6
@@ -58,7 +58,7 @@ enum empty_type {
58 EMPTY_UNSPECIFIED = -1,
59 EMPTY_DROP,
60 EMPTY_KEEP,
61 - EMPTY_ASK
61 + EMPTY_STOP
62 };
63
64 enum action {
@@ -951,10 +951,14 @@ static enum empty_type parse_empty_value(const char *value)
951 return EMPTY_DROP;
952 else if (!strcasecmp(value, "keep"))
953 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 + }
960
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);
962 }
963
964 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)
1137 "instead of ignoring them"),
1138 1, PARSE_OPT_HIDDEN),
1139 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)",
1141 N_("how to handle commits that become empty"),
1142 PARSE_OPT_NONEG, parse_opt_empty),
1143 OPT_CALLBACK_F('k', "keep-empty", &options, NULL,
@@ -1550,7 +1554,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1554
1555 if (options.empty == EMPTY_UNSPECIFIED) {
1556 if (options.flags & REBASE_INTERACTIVE_EXPLICIT)
1553 - options.empty = EMPTY_ASK;
1557 + options.empty = EMPTY_STOP;
1558 else if (options.exec.nr > 0)
1559 options.empty = EMPTY_KEEP;
1560 else
t/t3424-rebase-empty.sh
+16 -5
@@ -72,6 +72,17 @@ test_expect_success 'rebase --merge --empty=keep' '
72 test_cmp expect actual
73 '
74
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 +
86 test_expect_success 'rebase --merge --empty=ask' '
87 git checkout -B testing localmods &&
88 test_must_fail git rebase --merge --empty=ask upstream &&
@@ -101,9 +112,9 @@ test_expect_success 'rebase --interactive --empty=keep' '
112 test_cmp expect actual
113 '
114
104 -test_expect_success 'rebase --interactive --empty=ask' '
115 +test_expect_success 'rebase --interactive --empty=stop' '
116 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 &&
118
119 git rebase --skip &&
120
@@ -112,7 +123,7 @@ test_expect_success 'rebase --interactive --empty=ask' '
123 test_cmp expect actual
124 '
125
115 -test_expect_success 'rebase --interactive uses default of --empty=ask' '
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 &&
129
@@ -194,9 +205,9 @@ test_expect_success 'rebase --exec uses default of --empty=keep' '
205 test_cmp expect actual
206 '
207
197 -test_expect_success 'rebase --exec --empty=ask' '
208 +test_expect_success 'rebase --exec --empty=stop' '
209 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 &&
211
212 git rebase --skip &&
213