From: Junio C Hamano Date: Wed, 3 Jun 2026 23:14:06 +0000 (+0900) Subject: Merge branch 'js/parseopt-subcommand-autocorrection' into seen X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=e6f40464c175054f0885adf85ea69b1c13d84588;p=thirdparty%2Fgit.git Merge branch 'js/parseopt-subcommand-autocorrection' into seen The parse-options library learned to auto-correct misspelled subcommand names. * js/parseopt-subcommand-autocorrection: SQUASH??? doc: document autocorrect API parseopt: add tests for subcommand autocorrection parseopt: enable subcommand autocorrection for git-remote and git-notes parseopt: autocorrect mistyped subcommands autocorrect: provide config resolution API autocorrect: rename AUTOCORRECT_SHOW to AUTOCORRECT_HINT autocorrect: use mode and delay instead of magic numbers help: move tty check for autocorrection to autocorrect.c help: make autocorrect handling reusable parseopt: extract subcommand handling from parse_options_step() --- e6f40464c175054f0885adf85ea69b1c13d84588 diff --cc help.c index 46241492ce,16e5de973b..ab2458cb5c --- a/help.c +++ b/help.c @@@ -577,36 -544,16 +544,23 @@@ static int resolve_aliases(const char * const char *subsection, *key; size_t subsection_len; - if (!strcmp(var, "help.autocorrect")) { - int v = parse_autocorrect(value); - - if (!v) { - v = git_config_int(var, value, ctx->kvi); - if (v < 0 || v == 1) - v = AUTOCORRECT_IMMEDIATELY; - } - - cfg->autocorrect = v; - } - - /* Also use aliases for command lookup */ if (!parse_config_key(var, "alias", &subsection, &subsection_len, &key)) { + size_t key_len = strlen(key); + if (subsection) { /* [alias "name"] command = value */ if (!strcmp(key, "command")) - add_cmdname(&cfg->aliases, subsection, + add_cmdname(aliases, subsection, subsection_len); + else { + key = var + strlen("alias."); + key_len = strlen(key); - add_cmdname(&cfg->aliases, key, key_len); ++ add_cmdname(aliases, key, key_len); + } } else { /* alias.name = value */ - add_cmdname(&cfg->aliases, key, key_len); - add_cmdname(aliases, key, strlen(key)); ++ add_cmdname(aliases, key, key_len); } } diff --cc parse-options.c index a676da86f5,1a5feab5dd..efc9a9a3e9 --- a/parse-options.c +++ b/parse-options.c @@@ -5,8 -5,9 +5,10 @@@ #include "gettext.h" #include "strbuf.h" #include "string-list.h" +#include "strmap.h" #include "utf8.h" + #include "autocorrect.h" + #include "levenshtein.h" static int disallow_abbreviated_options;