Skip to content

Commit 5512376

Browse files
avarttaylorr
authored andcommitted
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 0afd556 (worktree: define subcommand -h in terms of command -h, 2022-10-13) for a recent example. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Đoàn Trần Công Danh <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 929bf9d commit 5512376

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

builtin/bisect--helper.c

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,40 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
2020
static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
2121
static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
2222

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,
3557
NULL
3658
};
3759

@@ -1411,11 +1433,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
14111433
OPT_SUBCOMMAND("run", &fn, cmd_bisect__run),
14121434
OPT_END()
14131435
};
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);
14161437

14171438
if (!fn)
1418-
usage_with_options(git_bisect_helper_usage, options);
1439+
usage_with_options(git_bisect_usage, options);
14191440
argc--;
14201441
argv++;
14211442

0 commit comments

Comments
 (0)