All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parse-options.c: display subcommands properly in check_typos
@ 2026-04-06 18:38 aubrey via GitGitGadget
  2026-04-06 19:27 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: aubrey via GitGitGadget @ 2026-04-06 18:38 UTC (permalink / raw)
  To: git; +Cc: aubrey, aubymori

From: aubymori <aubyomori@gmail.com>

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>
---
    parse-options.c: display subcommands properly in check_typos

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2084%2Faubymori%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2084/aubymori/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2084

 parse-options.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/parse-options.c b/parse-options.c
index a676da86f5..2c4530bb8c 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);
 		}
 	}

base-commit: 2855562ca6a9c6b0e7bc780b050c1e83c9fcfbd0
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-06 19:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-06 18:38 [PATCH] parse-options.c: display subcommands properly in check_typos aubrey via GitGitGadget
2026-04-06 19:27 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.