]> git.ipfire.org Git - thirdparty/git.git/commitdiff
alias: prepare for subsection aliases
authorJonatan Holmgren <jonatan@jontes.page>
Wed, 18 Feb 2026 21:57:35 +0000 (22:57 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Feb 2026 18:13:20 +0000 (10:13 -0800)
Switch git_unknown_cmd_config() from skip_prefix() to
parse_config_key() for alias parsing. This properly handles the
three-level config key structure and prepares for the new
alias.*.command subsection syntax in the next commit.

This is a compatibility break: the alias configuration parser used
to be overly permissive and accepted "alias.<subsection>.<key>" as
defining an alias "<subsection>.<key>". With this change,
alias.<subsection>.<key> entries are silently ignored (unless <key>
is "command", which will be given meaning in the next commit).

This behavior was arguably a bug, since config subsections were never
intended to work this way for aliases, and aliases with dots in their
names have never been documented or intentionally supported.

Signed-off-by: Jonatan Holmgren <jonatan@jontes.page>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
help.c

diff --git a/help.c b/help.c
index 84b9e5efe46e175f26173d7979811476916dd7f3..a781ebb98d98c8e691334d7418e0919f7e7959a4 100644 (file)
--- a/help.c
+++ b/help.c
@@ -574,7 +574,8 @@ static int git_unknown_cmd_config(const char *var, const char *value,
                                  void *cb)
 {
        struct help_unknown_cmd_config *cfg = cb;
-       const char *p;
+       const char *subsection, *key;
+       size_t subsection_len;
 
        if (!strcmp(var, "help.autocorrect")) {
                int v = parse_autocorrect(value);
@@ -589,8 +590,11 @@ static int git_unknown_cmd_config(const char *var, const char *value,
        }
 
        /* Also use aliases for command lookup */
-       if (skip_prefix(var, "alias.", &p))
-               add_cmdname(&cfg->aliases, p, strlen(p));
+       if (!parse_config_key(var, "alias", &subsection, &subsection_len,
+                             &key)) {
+               if (!subsection)
+                       add_cmdname(&cfg->aliases, key, strlen(key));
+       }
 
        return 0;
 }