Subject: Re: why can't one alias `git stash`?

From: Christoph Anton Mitterer <[email-masked]>
Date: Sat, 16 Aug 2025 04:11:20 +0200

On Fri, 2025-08-15 at 08:27 -0700, Junio C Hamano wrote:
>     $ git -c alias.loop='!git loop foo' alias foo ;# does not come
> back
>     ^C
> 
> To be honest, I do not offhand see a foolproof way to "fix" the
> latter.

I assume every aliasing step causes a new invocation of git - or are
aliases resolved in one process?

If the former, what about:
For every aliasing you append to some special env var the name of the
alias, and if the same is encountered again (or some maximum env var
size has been reached) you bail out with an error?

It's of course still not 100% foolproof, e.g. if users manually clear
the var or somehow else uses it.
And it requires that at least one char (that can be held by an env var)
is not allowed as an alias name, to be used as separator.

> It is true that it would break common expectations for script
> writers (to help other Git users) and those who help other Git users
> at their keyboards if we allowed to alias the basic command away and
> to change its behaviour radically.

As mentioned in the other thread, IMO it sounds rather brittle if
aliases are considered at all in scripting.

> But with so many configuration
> variable to alter behaviour for Porcelain commands, I am not sure
> how much it is helping the latter helpers these days.  For the
> former helpers, those who write their scripts with Porcelain
> commands are beyond salvation X-<.

Well I'd also be happy with a special porcelain option that allows be
to override the default of git stash O:-)

Thanks,
Chris.