git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* why can't one alias `git stash`?
@ 2025-08-15  0:33 Christoph Anton Mitterer
  2025-08-15  1:23 ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Anton Mitterer @ 2025-08-15  0:33 UTC (permalink / raw)
  To: git

Hey.

Personally, I've always disliked that `git stash` already does the
`push` and would have much more preferred it, if it did a `stash list`.

So I tried to solve this via an alias like:
[alias]
        stash = "!c(){ if [ \"$#\" -eq 0 ]; then git stash list; else git stash \"$@\"; fi; }; c"

which seems however to be ignored when the alias name is "stash" (it
works as it should when I use e.g. foo = ...).


Any idea why that doesn't work?


Also when using such shell functions seems to be not extensively
documented (or I didn't find it)... the example in git-config gives the
"!c()..." syntax but doesn't seem to tell what the ! is for?

Are these functions executed in a separate shell execution environment
(or could I accidentally override a function from some git shell
script)?

Is there any sanitisation of the environment that the shell gets (or
does it simply get whatever the user has)?
I mean a badly set IFS or similar could easily cause troubles.


Thanks,
Chris.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-08-19 21:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15  0:33 why can't one alias `git stash`? Christoph Anton Mitterer
2025-08-15  1:23 ` Junio C Hamano
2025-08-15  2:02   ` Christoph Anton Mitterer
2025-08-15  4:04     ` Elijah Newren
2025-08-15 11:22       ` rsbecker
2025-08-16  2:03         ` Christoph Anton Mitterer
2025-08-15 15:27       ` Junio C Hamano
2025-08-16  2:11         ` Christoph Anton Mitterer
2025-08-16  9:15           ` Matthias Aßhauer
2025-08-19  1:01           ` Junio C Hamano
2025-08-19 21:38             ` Christoph Anton Mitterer
2025-08-16  1:35       ` Christoph Anton Mitterer

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).