]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/parseopt-subcommand-autocorrection' into seen
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 May 2026 04:01:35 +0000 (13:01 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 May 2026 04:01:35 +0000 (13:01 +0900)
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()

1  2 
Makefile
builtin/remote.c
help.c
meson.build
parse-options.c
parse-options.h
t/meson.build
t/t7900-maintenance.sh

diff --cc Makefile
Simple merge
Simple merge
diff --cc help.c
index 46241492cee117cbeaa50047b2475737c555c23a,16e5de973bcc0948f949ab1df9b86b9229f8a83f..ab2458cb5ca272c17811322a98308e435dde6507
--- 1/help.c
--- 2/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);
-                               add_cmdname(&cfg->aliases, key, key_len);
 +                      else {
 +                              key = var + strlen("alias.");
 +                              key_len = strlen(key);
++                              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 meson.build
Simple merge
diff --cc parse-options.c
index a676da86f5d617bd4a84d8301b77115eb62c3b19,1a5feab5dd3f780cfc012c08df9a58123e64dc79..efc9a9a3e94515b9c33ef0a152f474f67764cbcd
@@@ -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;
  
diff --cc parse-options.h
Simple merge
diff --cc t/meson.build
Simple merge
Simple merge