git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tim Schumacher <timschumi@gmx.de>
To: git@vger.kernel.org
Subject: [RFC PATCH] Allow aliases that include other aliases
Date: Tue,  4 Sep 2018 19:39:15 +0200	[thread overview]
Message-ID: <20180904173915.2393-1-timschumi@gmx.de> (raw)

Aliases can only contain non-alias git commands and arguments,
but not other user-defined aliases. Resolving nested aliases
is prevented by breaking the loop after the first alias was
processed, git then fails with a command-not-found error.

Allow resolving nested aliases by not breaking the loop in
run_argv() after the first alias was processed. Instead, continue
incrementing done_alias until handle_alias() fails, which means
that there are no further aliases that can be processed.

---

I submitted this as RFC because I'm not sure whether disallowing
nested aliases was an intentional design choice. The done_alias
check implies that disallowing is intended, but the direct
recursion check for aliases that call themselves opposes that.

Furthermore, including this patch allows creating a looping state,
since the recursion check only checks if an alias is directly calling
itself.
One solution would be to break the loop as soon as done_alias reaches
a certain value, but that requires setting an arbitrary point of "too
many recursions".
A list of already resolved aliases and breaking the loop as soon as
an alias is resolved twice would probably do the trick, but
implementing that is well beyond the point of what I'm capable of
doing.

---
 git.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/git.c b/git.c
index c27c38738..9d3cf5797 100644
--- a/git.c
+++ b/git.c
@@ -695,11 +695,9 @@ static int run_argv(int *argcp, const char ***argv)
 		 * of overriding "git log" with "git show" by having
 		 * alias.log = show
 		 */
-		if (done_alias)
-			break;
 		if (!handle_alias(argcp, argv))
 			break;
-		done_alias = 1;
+		done_alias++;
 	}
 
 	return done_alias;
-- 
2.19.0.rc1.2.g7460ee143


             reply	other threads:[~2018-09-04 17:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 17:39 Tim Schumacher [this message]
2018-09-04 17:55 ` [RFC PATCH] Allow aliases that include other aliases Junio C Hamano
2018-09-04 20:11   ` Jeff King

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=20180904173915.2393-1-timschumi@gmx.de \
    --to=timschumi@gmx.de \
    --cc=git@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).