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/220111.86a6g3yqf9.gmgdl@evledraar.gmail.com/ Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Josh Steadmon committed
Jan 18, 2022 at 12:49 UTC
15f002812f858b49ce7641eb191561843cf31f00
2 files changed
+5
-5
builtin/branch.c
+2
-2
@@ -632,9 +632,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
632
OPT__VERBOSE(&filter.verbose,
633
N_("show hash and subject, give twice for upstream branch")),
634
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"),
636
N_("set branch tracking configuration"),
637
- PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
637
+ PARSE_OPT_OPTARG,
638
parse_opt_tracking_mode),
639
OPT_SET_INT_F(0, "set-upstream", &track, N_("do not use"),
640
BRANCH_TRACK_OVERRIDE, PARSE_OPT_HIDDEN),
builtin/checkout.c
+3
-3
@@ -1530,9 +1530,9 @@ static struct option *add_common_switch_branch_options(
1530
{
1531
struct option options[] = {
1532
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,
1536
parse_opt_tracking_mode),
1537
OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"),
1538
PARSE_OPT_NOCOMPLETE),