git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: Christoph Anton Mitterer <calestyo@scientia.org>,  git@vger.kernel.org
Subject: Re: why can't one alias `git stash`?
Date: Fri, 15 Aug 2025 08:27:47 -0700	[thread overview]
Message-ID: <xmqqjz34txjg.fsf@gitster.g> (raw)
In-Reply-To: <CABPp-BHt80YD9bzWeC+r5qxJ0Vp+zRsJZsKDU_GA39CXmuYe5A@mail.gmail.com> (Elijah Newren's message of "Thu, 14 Aug 2025 21:04:03 -0700")

Elijah Newren <newren@gmail.com> writes:

> The documentation you are responding to didn't talk about "other"
> commands, it talked about "existing" commands.  Your alias, meant to
> invoke `git stash` with different arguments, would hide the existing
> `git stash` command.

Correct.

> It might also be an infinite loop of sorts, since your `git stash`
> alias invokes `git stash ...` which is...itself.

True.  But we do not do a very good job preventing this to happen.

    $ git -c alias.loop='loop foo' loop foo
    fatal: recursive alias: loop
    $ 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.

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

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

Thanks.

  parent reply	other threads:[~2025-08-15 15:27 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 [this message]
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

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=xmqqjz34txjg.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=calestyo@scientia.org \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).