Re: [PATCH v4 2/7] git: allow alias-shadowing deprecated builtins

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 14, 2025 at 07:24:14PM +0200, Kristoffer Haugsbakk wrote:

> > If you want to get rid of that last paragraph, I think it really is as
> > simple as checking the expanded alias new_argv[0] as soon as we see it,
> > like:
> 
> I tried using both of these changes (the patches) but the `alias...`
> test suite started failing.

Hmm, it still passes for me. If I do just this on top of your v5, it
likewise passes (except for your new test which expects the redundant
line).

diff --git a/git.c b/git.c
index 10315742f8..c5fad56813 100644
--- a/git.c
+++ b/git.c
@@ -425,7 +425,10 @@ static int handle_alias(struct strvec *args, struct string_list *expanded_aliase
 		if (!strcmp(alias_command, new_argv[0]))
 			die(_("recursive alias: %s"), alias_command);
 
-		seen = unsorted_string_list_lookup(expanded_aliases, args->v[0]);
+		string_list_append(expanded_aliases, alias_command);
+		seen = unsorted_string_list_lookup(expanded_aliases,
+						   new_argv[0]);
+
 		if (seen) {
 			struct strbuf sb = STRBUF_INIT;
 			for (size_t i = 0; i < expanded_aliases->nr; i++) {
@@ -441,8 +444,6 @@ static int handle_alias(struct strvec *args, struct string_list *expanded_aliase
 			      " not terminate:%s"), expanded_aliases->items[0].string, sb.buf);
 		}
 
-		string_list_append(expanded_aliases, args->v[0]);
-
 		trace_argv_printf(new_argv,
 				  "trace: alias expansion: %s =>",
 				  alias_command);

> I ended up with not changing it for v5.  I missed the first time around
> that this informational message is only “logged” in the specific case of
> `<git cmd> -h`.  In turn you only get one more line of output when you
> are (1) chaining deprecated aliases, and (2) making a loop.

I don't think (1) is necessary. With your v5 I get:

  $ ./git -c alias.one=two -c alias.two=one one -h
  'one' is aliased to 'two'
  'two' is aliased to 'one'
  'one' is aliased to 'two'
  fatal: alias loop detected: expansion of 'one' does not terminate:
    one <==
    two ==>

So the extra line is printed even without deprecated aliases.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux