git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] alias: restore support for simple dotted aliases

From
Jeff King <peff@peff.net>
Date
Apr 25, 2026, 23:47 UTC
Message-ID
<20260425234700.GB29816@coredump.intra.peff.net>
In-Reply-To
<20260425232916.GA29816@coredump.intra.peff.net>
On Sat, Apr 25, 2026 at 07:29:16PM -0400, Jeff King wrote:
Show 14 quoted lines
> On Sat, Apr 25, 2026 at 11:57:24AM +0200, Jonatan Holmgren wrote:
> 
> > That is a challenge we are going to have to consider. I think reserving
> > `command` is a worthwhile compromise, but obviously we cannot do that for
> > arbitrary future keys such as `help`, `hidden`, etc.
> 
> We don't necessarily have to reserve them. When we see alias.foo.bar, we
> could consider it as both alias "foo.bar" and the "bar" key of alias
> "foo", without regard to what is in "bar" (i.e., whether it is "command"
> or "help", etc). I.e., don't "fall back" but allow two overlapping
> namespace.s
> 
> That is the most backwards-compatible thing we could do, but does create
> some interesting situations.
For reference, I mean something like this:
diff --git a/alias.c b/alias.c
index ec9833dd30..07c6bd3645 100644
--- a/alias.c
+++ b/alias.c
@@ -34,16 +34,20 @@ static int config_alias_cb(const char *var, const char *value,
 	if (subsection && !subsection_len)
 		subsection = NULL;
 
-	if (subsection && strcmp(key, "command"))
-		return 0;
-
 	if (data->alias) {
 		int match;
 
 		if (subsection)
-			match = (strlen(data->alias) == subsection_len &&
-				 !strncmp(data->alias, subsection,
-					  subsection_len));
+			/*
+			 * alias.foo.command always matches "foo", but for
+			 * historical compatibility also match alias.foo.bar as
+			 * "foo.bar", even when "bar" is "command" or any other
+			 * key we happen to know about.
+			 */
+			match = (!strcmp(key, "command") &&
+				 strlen(data->alias) == subsection_len &&
+				 !strncmp(data->alias, subsection, subsection_len))
+				|| !strcmp(data->alias, subsection);
 		else
 			match = !strcasecmp(data->alias, key);
 
@@ -59,8 +63,23 @@ static int config_alias_cb(const char *var, const char *value,
 			return config_error_nonbool(var);
 
 		if (subsection)
+			/*
+			 * If it's not alias.foo.command, then either it's a
+			 * historical alias (git "foo.bar"), or it's some
+			 * metadata not support yet by this version
+			 * ("alias.foo.help" or similar).
+			 *
+			 * We'll guess it's the former and include the whole
+			 * "foo.bar" in the list.
+			 *
+			 * We might want to suppress duplicates when we see both
+			 * alias.foo.command and alias.foo.help, since that's
+			 * what a hypothetical future version might understand.
+			 */
 			item = string_list_append_nodup(data->list,
-				xmemdupz(subsection, subsection_len));
+							!strcmp(key, "command")
+							? xmemdupz(subsection, subsection_len)
+							: xstrdup(subsection));
 		else
 			item = string_list_append(data->list, key);
 		item->util = xstrdup(value);

-Peff
Previous: Jeff KingNext: Jonatan Holmgren
Message 12 of 18 in “Bug: Hierarchical Aliases no longer work in 2.54.0”
  1. Grossfeld, MichaelApr 23, 2026
  2. Jeff KingApr 23, 2026
  3. Michael GrossfeldApr 23, 2026
  4. René ScharfeApr 23, 2026
  5. Michael GrossfeldApr 23, 2026
  6. Jonatan HolmgrenApr 24, 2026
  7. alias: restore support for simple dotted aliasesJonatan Holmgren, Apr 24, 2026
  8. Kristoffer HaugsbakkApr 24, 2026
  9. Junio C HamanoApr 24, 2026
  10. Jonatan HolmgrenApr 25, 2026
  11. Jeff KingApr 25, 2026
  12. Jeff KingApr 25, 2026
  13. Jonatan HolmgrenApr 26, 2026
  14. Jeff KingApr 26, 2026
  15. Jonatan HolmgrenApr 27, 2026
  16. Junio C HamanoMay 12, 2026
  17. Jeff KingMay 19, 2026
  18. alias: restore support for simple dotted aliasesJonatan Holmgren, Apr 24, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.