Skip to content

Commit f87b5e3

Browse files
committed
parse-options.c: display subcommands properly in check_typos
Before this, mistyping a subcommand with one dash (e.g. `git stash -list`) would display a message telling the user to try it with two dashes. Since subcommands are parsed with no dashes, this is incorrect and simply results in the help message for that command being shown. This commit changes check_typos to check the command type and display a proper message for subcommands. Signed-off-by: aubymori <aubyomori@gmail.com>
1 parent 2855562 commit f87b5e3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

parse-options.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,10 @@ static void check_typos(const char *arg, const struct option *options)
633633
if (!options->long_name)
634634
continue;
635635
if (starts_with(options->long_name, arg)) {
636-
error(_("did you mean `--%s` (with two dashes)?"), arg);
636+
if (options->type == OPTION_SUBCOMMAND)
637+
error(_("did you mean `%s` (with no dash)?"), arg);
638+
else
639+
error(_("did you mean `--%s` (with two dashes)?"), arg);
637640
exit(129);
638641
}
639642
}

0 commit comments

Comments
 (0)