Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Jonatan Holmgren <jonatan@jontes.page>
Cc: Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, rsch@web.de, michael.grossfeld@amd.com
Subject: Re: [PATCH] alias: restore support for simple dotted aliases
Date: Sat, 25 Apr 2026 19:47:00 -0400	[thread overview]
Message-ID: <20260425234700.GB29816@coredump.intra.peff.net> (raw)
In-Reply-To: <20260425232916.GA29816@coredump.intra.peff.net>

On Sat, Apr 25, 2026 at 07:29:16PM -0400, Jeff King wrote:

> 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

  reply	other threads:[~2026-04-25 23:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 18:19 Bug: Hierarchical Aliases no longer work in 2.54.0 Grossfeld, Michael
2026-04-23 21:12 ` Jeff King
2026-04-23 22:55   ` Michael Grossfeld
2026-04-23 21:36 ` René Scharfe
2026-04-23 22:46   ` Michael Grossfeld
2026-04-24  7:29 ` Jonatan Holmgren
2026-04-24 15:10 ` [PATCH] alias: restore support for simple dotted aliases Jonatan Holmgren
2026-04-24 16:09   ` Kristoffer Haugsbakk
2026-04-24 22:47   ` Junio C Hamano
2026-04-25  9:57     ` Jonatan Holmgren
2026-04-25 23:29       ` Jeff King
2026-04-25 23:47         ` Jeff King [this message]
2026-04-26 19:21         ` Jonatan Holmgren
2026-04-26 23:01           ` Jeff King
2026-04-27  8:36             ` Jonatan Holmgren
2026-05-12  4:43               ` Junio C Hamano
2026-04-24 16:17 ` Jonatan Holmgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260425234700.GB29816@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonatan@jontes.page \
    --cc=michael.grossfeld@amd.com \
    --cc=rsch@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox