Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
aubymori committed Apr 6, 2026
commit f87b5e32e53f5bf3608a244b064aaea27a1ee01a
5 changes: 4 additions & 1 deletion parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Loading