am, rebase: fix arghelp syntax of --empty

Use parentheses and pipes to present alternatives in the argument help for the --empty options of git am and git rebase, like in the rest of the documentation. While at it remove a stray use of the enum empty_action value STOP_ON_EMPTY_COMMIT to indicate that no short option is present. While it has a value of 0 and thus there is no user-visible change, that enum is not meant to hold short option characters. Hard-code 0, like we do for other options without a short option. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 28, 2023 at 13:58 UTC f7c1b23819ec8b838e5427ed2e7cd12c81a796d2
3 files changed +4 -4
Documentation/git-rebase.txt
+2 -2
@@ -289,7 +289,7 @@ See also INCOMPATIBLE OPTIONS below.
289 +
290 See also INCOMPATIBLE OPTIONS below.
291
292 ---empty={drop,keep,ask}::
292 +--empty=(drop|keep|ask)::
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
@@ -695,7 +695,7 @@ be dropped automatically with `--no-keep-empty`).
695 Similar to the apply backend, by default the merge backend drops
696 commits that become empty unless `-i`/`--interactive` is specified (in
697 which case it stops and asks the user what to do). The merge backend
698 -also has an `--empty={drop,keep,ask}` option for changing the behavior
698 +also has an `--empty=(drop|keep|ask)` option for changing the behavior
699 of handling commits that become empty.
700
701 Directory rename detection
builtin/am.c
+1 -1
@@ -2419,7 +2419,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
2419 { OPTION_STRING, 'S', "gpg-sign", &state.sign_commit, N_("key-id"),
2420 N_("GPG-sign commits"),
2421 PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
2422 - OPT_CALLBACK_F(STOP_ON_EMPTY_COMMIT, "empty", &state.empty_type, "{stop,drop,keep}",
2422 + OPT_CALLBACK_F(0, "empty", &state.empty_type, "(stop|drop|keep)",
2423 N_("how to handle empty patches"),
2424 PARSE_OPT_NONEG, am_option_parse_empty),
2425 OPT_HIDDEN_BOOL(0, "rebasing", &state.rebasing,
builtin/rebase.c
+1 -1
@@ -1147,7 +1147,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1147 "instead of ignoring them"),
1148 1, PARSE_OPT_HIDDEN),
1149 OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
1150 - OPT_CALLBACK_F(0, "empty", &options, "{drop,keep,ask}",
1150 + OPT_CALLBACK_F(0, "empty", &options, "(drop|keep|ask)",
1151 N_("how to handle commits that become empty"),
1152 PARSE_OPT_NONEG, parse_opt_empty),
1153 OPT_CALLBACK_F('k', "keep-empty", &options, NULL,