From eede028f06259d8a2501eb8bd5ca5eafd7885504 Mon Sep 17 00:00:00 2001 From: aubymori Date: Mon, 6 Apr 2026 13:24:39 -0500 Subject: [PATCH] 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 --- parse-options.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parse-options.c b/parse-options.c index a676da86f5d617..2c4530bb8cfbda 100644 --- a/parse-options.c +++ b/parse-options.c @@ -633,7 +633,10 @@ static void check_typos(const char *arg, const struct option *options) if (!options->long_name) continue; if (starts_with(options->long_name, arg)) { - error(_("did you mean `--%s` (with two dashes)?"), arg); + if (options->type == OPTION_SUBCOMMAND) + error(_("did you mean `%s` (with no dash)?"), arg); + else + error(_("did you mean `--%s` (with two dashes)?"), arg); exit(129); } }