Skip to content

Commit 15f0028

Browse files
steadmongitster
authored andcommitted
branch,checkout: fix --track usage strings
As Ævar pointed out in [1], the use of PARSE_OPT_LITERAL_ARGHELP with a list of allowed parameters is not recommended. Both git-branch and git-checkout were changed in d311566 (branch: add flags and config to inherit tracking, 2021-12-20) to use this discouraged combination for their --track flags. Fix this by removing PARSE_OPT_LITERAL_ARGHELP, and changing the arghelp to simply be "mode". Users may discover allowed values in the manual pages. [1]: https://lore.kernel.org/git/[email protected]/ Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 44f14a9 commit 15f0028

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

builtin/branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
632632
OPT__VERBOSE(&filter.verbose,
633633
N_("show hash and subject, give twice for upstream branch")),
634634
OPT__QUIET(&quiet, N_("suppress informational messages")),
635-
OPT_CALLBACK_F('t', "track", &track, "direct|inherit",
635+
OPT_CALLBACK_F('t', "track", &track, N_("mode"),
636636
N_("set branch tracking configuration"),
637-
PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
637+
PARSE_OPT_OPTARG,
638638
parse_opt_tracking_mode),
639639
OPT_SET_INT_F(0, "set-upstream", &track, N_("do not use"),
640640
BRANCH_TRACK_OVERRIDE, PARSE_OPT_HIDDEN),

builtin/checkout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,9 +1530,9 @@ static struct option *add_common_switch_branch_options(
15301530
{
15311531
struct option options[] = {
15321532
OPT_BOOL('d', "detach", &opts->force_detach, N_("detach HEAD at named commit")),
1533-
OPT_CALLBACK_F('t', "track", &opts->track, "direct|inherit",
1534-
N_("set up tracking mode (see git-pull(1))"),
1535-
PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
1533+
OPT_CALLBACK_F('t', "track", &opts->track, N_("mode"),
1534+
N_("set branch tracking configuration"),
1535+
PARSE_OPT_OPTARG,
15361536
parse_opt_tracking_mode),
15371537
OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"),
15381538
PARSE_OPT_NOCOMPLETE),

0 commit comments

Comments
 (0)