Skip to content

Commit d7f817d

Browse files
avargitster
authored andcommitted
help: note the option name on option incompatibility
Change the errors added in d35d03c (help: simplify by moving to OPT_CMDMODE(), 2021-09-22) to quote the offending option at the user when invoked as e.g.: git help --guides garbage Now instead of: fatal: this option doesn't take any other arguments We'll emit: fatal: the '--guides' option doesn't take any non-option arguments Let's also rename the function, as it will be extended to do other checks that aren't "no extra argc" in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6fb427a commit d7f817d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

builtin/help.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,12 @@ static const char *check_git_cmd(const char* cmd)
574574
return cmd;
575575
}
576576

577-
static void no_extra_argc(int argc)
577+
static void opt_mode_usage(int argc, const char *opt_mode)
578578
{
579579
if (argc)
580-
usage_msg_opt(_("this option doesn't take any other arguments"),
581-
builtin_help_usage, builtin_help_options);
580+
usage_msg_optf(_("the '%s' option doesn't take any non-option arguments"),
581+
builtin_help_usage, builtin_help_options,
582+
opt_mode);
582583
}
583584

584585
int cmd_help(int argc, const char **argv, const char *prefix)
@@ -604,20 +605,20 @@ int cmd_help(int argc, const char **argv, const char *prefix)
604605
printf("%s\n", _(git_more_info_string));
605606
break;
606607
case HELP_ACTION_GUIDES:
607-
no_extra_argc(argc);
608+
opt_mode_usage(argc, "--guides");
608609
list_guides_help();
609610
printf("%s\n", _(git_more_info_string));
610611
return 0;
611612
case HELP_ACTION_CONFIG_FOR_COMPLETION:
612-
no_extra_argc(argc);
613+
opt_mode_usage(argc, "--config-for-completion");
613614
list_config_help(SHOW_CONFIG_VARS);
614615
return 0;
615616
case HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION:
616-
no_extra_argc(argc);
617+
opt_mode_usage(argc, "--config-sections-for-completion");
617618
list_config_help(SHOW_CONFIG_SECTIONS);
618619
return 0;
619620
case HELP_ACTION_CONFIG:
620-
no_extra_argc(argc);
621+
opt_mode_usage(argc, "--config");
621622
setup_pager();
622623
list_config_help(SHOW_CONFIG_HUMAN);
623624
printf("\n%s\n", _("'git help config' for more information"));

0 commit comments

Comments
 (0)