public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Christoph Anton Mitterer <calestyo@scientia•org>
To: Elijah Newren <newren@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: why can't one alias `git stash`?
Date: Sat, 16 Aug 2025 03:35:47 +0200	[thread overview]
Message-ID: <fdb7d4da229dc41302d1c17871674cb41d3956ce.camel@scientia.org> (raw)
In-Reply-To: <CABPp-BHt80YD9bzWeC+r5qxJ0Vp+zRsJZsKDU_GA39CXmuYe5A@mail.gmail.com>

On Thu, 2025-08-14 at 21:04 -0700, Elijah Newren wrote:
> No.  And there won't be one in the future either; see e.g.
> https://lore.kernel.org/git/alpine.DEB.1.00.0903070407480.10279@pacific.mpi-cbg.de/

At least the "it makes it hard for users to understand" argument seems
a bit weak.

I mean isn't that's also the case with shell aliases and the whole
point of them is to customise the behaviour for the user (which is btw
also done by many git-config options, which another user that uses my
settings may not be familiar with).



> And it'd mean that other folks who use git commands in their scripts
> now can't rely on any git commands doing what their documentation
> claims.

TBH, I wasn't even aware that git aliases are applied from scripts.

Isn't that anyway a pretty dangerous game?
I mean I could define an alias that works right now, as it doesn't hid
an actual command... my script relies on that alias working.
And the next git version introduces a command of the same name (and my
script breaks).

There's good reason that shell aliasing is per default not active in
non-interactive shells.

> Doesn't it detail what happens already?
> 
>            If the alias expansion is prefixed with an exclamation
> point, it will be treated as a shell command. For example, defining
> alias.new = !gitk --all --not
>            ORIG_HEAD, the invocation git new is equivalent to running
> the shell command gitk --all --not ORIG_HEAD. Note that shell
> commands
> will be executed from the
>            top-level directory of a repository, which may not
> necessarily be the current directory.  GIT_PREFIX is set as returned
> by running git rev-parse --show-prefix
>            from the original current directory. See git-rev-parse(1).
> 
> What is missing from this explanation?

Well, what I've said in my initial post.
Is the shell execution environment in any way sanitised (like which
IFS, PATH, whatever are set) or does it even share the env from some
git shell script that may execute the alias shell command (as in dot
sourcing).
Perhaps also *which* shell is used? Is it always /bin/sh or whatever
shell the user has configured as login shell?
Will e.g. profile/rc files be loaded or not.

Admittedly some information might be overkill, but at least I'd wanna
know if using the wrong function/var names in my alias command, could
cause troubles for git.


Cheers,
Chris.

      parent reply	other threads:[~2025-08-16  1:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=fdb7d4da229dc41302d1c17871674cb41d3956ce.camel@scientia.org \
    --to=calestyo@scientia$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=newren@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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