alias: prepare for subsection aliases

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>

Jonatan Holmgren committed Feb 18, 2026 at 22:57 UTC 2ad33ea6b5c0a5670a757c9b594cc07321324e80
1 file changed +7 -3
help.c
+7 -3
@@ -574,7 +574,8 @@ static int git_unknown_cmd_config(const char *var, const char *value,
574 void *cb)
575 {
576 struct help_unknown_cmd_config *cfg = cb;
577 - const char *p;
577 + const char *subsection, *key;
578 + size_t subsection_len;
579
580 if (!strcmp(var, "help.autocorrect")) {
581 int v = parse_autocorrect(value);
@@ -589,8 +590,11 @@ static int git_unknown_cmd_config(const char *var, const char *value,
590 }
591
592 /* Also use aliases for command lookup */
592 - if (skip_prefix(var, "alias.", &p))
593 - add_cmdname(&cfg->aliases, p, strlen(p));
593 + if (!parse_config_key(var, "alias", &subsection, &subsection_len,
594 + &key)) {
595 + if (!subsection)
596 + add_cmdname(&cfg->aliases, key, strlen(key));
597 + }
598
599 return 0;
600 }