]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect--helper: emit usage for "git bisect"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 10 Nov 2022 16:36:43 +0000 (23:36 +0700)
committerTaylor Blau <me@ttaylorr.com>
Fri, 11 Nov 2022 22:05:58 +0000 (17:05 -0500)
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>
builtin/bisect--helper.c

index f28bedac6ae520b39e5492331a4cde6fe5d26a09..1ff2d4ea3fee612c281f8bb69585a240d635434a 100644 (file)
@@ -20,18 +20,40 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
 static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
 static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
 
-static const char * const git_bisect_helper_usage[] = {
-       N_("git bisect--helper --bisect-reset [<commit>]"),
-       "git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]",
-       N_("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
-                                           " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
-       "git bisect--helper --bisect-next",
-       N_("git bisect--helper --bisect-state (bad|new) [<rev>]"),
-       N_("git bisect--helper --bisect-state (good|old) [<rev>...]"),
-       N_("git bisect--helper --bisect-replay <filename>"),
-       N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
-       "git bisect--helper --bisect-visualize",
-       N_("git bisect--helper --bisect-run <cmd>..."),
+#define BUILTIN_GIT_BISECT_START_USAGE \
+       N_("git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>]" \
+          "    [--no-checkout] [--first-parent] [<bad> [<good>...]] [--]" \
+          "    [<pathspec>...]")
+#define BUILTIN_GIT_BISECT_STATE_USAGE \
+       N_("git bisect (good|bad) [<rev>...]")
+#define BUILTIN_GIT_BISECT_TERMS_USAGE \
+       "git bisect terms [--term-good | --term-bad]"
+#define BUILTIN_GIT_BISECT_SKIP_USAGE \
+       N_("git bisect skip [(<rev>|<range>)...]")
+#define BUILTIN_GIT_BISECT_NEXT_USAGE \
+       "git bisect next"
+#define BUILTIN_GIT_BISECT_RESET_USAGE \
+       N_("git bisect reset [<commit>]")
+#define BUILTIN_GIT_BISECT_VISUALIZE_USAGE \
+       "git bisect visualize"
+#define BUILTIN_GIT_BISECT_REPLAY_USAGE \
+       N_("git bisect replay <logfile>")
+#define BUILTIN_GIT_BISECT_LOG_USAGE \
+       "git bisect log"
+#define BUILTIN_GIT_BISECT_RUN_USAGE \
+       N_("git bisect run <cmd>...")
+
+static const char * const git_bisect_usage[] = {
+       BUILTIN_GIT_BISECT_START_USAGE,
+       BUILTIN_GIT_BISECT_STATE_USAGE,
+       BUILTIN_GIT_BISECT_TERMS_USAGE,
+       BUILTIN_GIT_BISECT_SKIP_USAGE,
+       BUILTIN_GIT_BISECT_NEXT_USAGE,
+       BUILTIN_GIT_BISECT_RESET_USAGE,
+       BUILTIN_GIT_BISECT_VISUALIZE_USAGE,
+       BUILTIN_GIT_BISECT_REPLAY_USAGE,
+       BUILTIN_GIT_BISECT_LOG_USAGE,
+       BUILTIN_GIT_BISECT_RUN_USAGE,
        NULL
 };
 
@@ -1411,11 +1433,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
                OPT_SUBCOMMAND("run", &fn, cmd_bisect__run),
                OPT_END()
        };
-       argc = parse_options(argc, argv, prefix, options,
-                            git_bisect_helper_usage, 0);
+       argc = parse_options(argc, argv, prefix, options, git_bisect_usage, 0);
 
        if (!fn)
-               usage_with_options(git_bisect_helper_usage, options);
+               usage_with_options(git_bisect_usage, options);
        argc--;
        argv++;