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 19, 2025, 21:38 UTC
Message-ID
<67090cec91d92af5616651de29950ecb3e8810f6.camel@scientia.org>
In-Reply-To
<xmqqh5y4gm4v.fsf@gitster.g>
On Mon, 2025-08-18 at 18:01 -0700, Junio C Hamano wrote:
Show 6 quoted lines
> As a program, how would you tell when you are run by a script?
> 
> If you are a shell, you go into "interactive" mode when you are
> taking your command stream from a tty, and otherwise assume you are
> not interactive.  The same trick would not work at all for programs
> started by a shell, would it?

Not for all, but it might still give enough "teaching" to prevent people from using aliases in scripts.

Checking whether the parent process is a well known shell would probably not help, as it would also be for the interactive case, where aliasing is wanted.

> Asking script writers to pass "--no-alias" option to all of their
> "git" invocation will probably not be a viable way forward, either.

Again at least not a safe one. And doing the opposite, i.e. requring -- enable-aliasing (which people would then have to set as shell alias), would probably end up in generating quite a few annoyed people. ;-)

It could be made optional. E.g. some gitconf option that per default enables aliasing always but allows to require a --aliasing option (which then again is intended to be set via a shell alias) in order for git aliasing to be enabled.

Whether it's worth the effort is of course another question.

Cheers, Chris.

Previous: Junio C HamanoNext: Christoph Anton Mitterer
Message 11 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.