bisect--helper: emit usage for "git bisect"

In subsequent commits we'll be removing "git-bisect.sh" in favor of promoting "bisect--helper" to a "bisect" built-in. In doing that we'll first need to have it support "git bisect--helper <cmd>" rather than "git bisect--helper --<cmd>", and then finally have its "-h" output claim to be "bisect" rather than "bisect--helper". Instead of suffering that churn let's start claiming to be "git bisect" now. In just a few commits this will be true, and in the meantime emitting the "wrong" usage information from the helper is a small price to pay to avoid the churn. Let's also declare "BUILTIN_*" macros, when we eventually migrate the sub-commands themselves to parse_options() we'll be able to re-use the strings. See 0afd556b2e1 (worktree: define subcommand -h in terms of command -h, 2022-10-13) for a recent example. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>

Ævar Arnfjörð Bjarmason committed Nov 10, 2022 at 23:36 UTC 5512376ae14b07bb3c71c3ea7b4a181dd0fb4172
1 file changed +36 -15
builtin/bisect--helper.c
+36 -15
@@ -20,18 +20,40 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
20 static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
21 static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
22
23 -static const char * const git_bisect_helper_usage[] = {
24 - N_("git bisect--helper --bisect-reset [<commit>]"),
25 - "git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]",
26 - N_("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
27 - " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
28 - "git bisect--helper --bisect-next",
29 - N_("git bisect--helper --bisect-state (bad|new) [<rev>]"),
30 - N_("git bisect--helper --bisect-state (good|old) [<rev>...]"),
31 - N_("git bisect--helper --bisect-replay <filename>"),
32 - N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
33 - "git bisect--helper --bisect-visualize",
34 - N_("git bisect--helper --bisect-run <cmd>..."),
23 +#define BUILTIN_GIT_BISECT_START_USAGE \
24 + N_("git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>]" \
25 + " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--]" \
26 + " [<pathspec>...]")
27 +#define BUILTIN_GIT_BISECT_STATE_USAGE \
28 + N_("git bisect (good|bad) [<rev>...]")
29 +#define BUILTIN_GIT_BISECT_TERMS_USAGE \
30 + "git bisect terms [--term-good | --term-bad]"
31 +#define BUILTIN_GIT_BISECT_SKIP_USAGE \
32 + N_("git bisect skip [(<rev>|<range>)...]")
33 +#define BUILTIN_GIT_BISECT_NEXT_USAGE \
34 + "git bisect next"
35 +#define BUILTIN_GIT_BISECT_RESET_USAGE \
36 + N_("git bisect reset [<commit>]")
37 +#define BUILTIN_GIT_BISECT_VISUALIZE_USAGE \
38 + "git bisect visualize"
39 +#define BUILTIN_GIT_BISECT_REPLAY_USAGE \
40 + N_("git bisect replay <logfile>")
41 +#define BUILTIN_GIT_BISECT_LOG_USAGE \
42 + "git bisect log"
43 +#define BUILTIN_GIT_BISECT_RUN_USAGE \
44 + N_("git bisect run <cmd>...")
45 +
46 +static const char * const git_bisect_usage[] = {
47 + BUILTIN_GIT_BISECT_START_USAGE,
48 + BUILTIN_GIT_BISECT_STATE_USAGE,
49 + BUILTIN_GIT_BISECT_TERMS_USAGE,
50 + BUILTIN_GIT_BISECT_SKIP_USAGE,
51 + BUILTIN_GIT_BISECT_NEXT_USAGE,
52 + BUILTIN_GIT_BISECT_RESET_USAGE,
53 + BUILTIN_GIT_BISECT_VISUALIZE_USAGE,
54 + BUILTIN_GIT_BISECT_REPLAY_USAGE,
55 + BUILTIN_GIT_BISECT_LOG_USAGE,
56 + BUILTIN_GIT_BISECT_RUN_USAGE,
57 NULL
58 };
59
@@ -1411,11 +1433,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
1433 OPT_SUBCOMMAND("run", &fn, cmd_bisect__run),
1434 OPT_END()
1435 };
1414 - argc = parse_options(argc, argv, prefix, options,
1415 - git_bisect_helper_usage, 0);
1436 + argc = parse_options(argc, argv, prefix, options, git_bisect_usage, 0);
1437
1438 if (!fn)
1418 - usage_with_options(git_bisect_helper_usage, options);
1439 + usage_with_options(git_bisect_usage, options);
1440 argc--;
1441 argv++;
1442