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

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

From
Christoph Anton Mitterer <calestyo@scientia.org>
Date
Aug 16, 2025, 02:11 UTC
Message-ID
<d8b279098a41949eef06f26d3f09c3950486380b.camel@scientia.org>
In-Reply-To
<xmqqjz34txjg.fsf@gitster.g>
On Fri, 2025-08-15 at 08:27 -0700, Junio C Hamano wrote:
Show 6 quoted lines
>     $ 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.

Show 5 quoted lines
> 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.

Previous: Junio C HamanoNext: Matthias Aßhauer
Message 8 of 12 in “why can't one alias `git stash`?”
  1. Christoph Anton MittererAug 15, 2025
  2. Junio C HamanoAug 15, 2025
  3. Christoph Anton MittererAug 15, 2025
  4. Elijah NewrenAug 15, 2025
  5. rsbecker@nexbridge.comAug 15, 2025
  6. Christoph Anton MittererAug 16, 2025
  7. Junio C HamanoAug 15, 2025
  8. Christoph Anton MittererAug 16, 2025
  9. Matthias AßhauerAug 16, 2025
  10. Junio C HamanoAug 19, 2025
  11. Christoph Anton MittererAug 19, 2025
  12. Christoph Anton MittererAug 16, 2025

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.