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

Re: [PATCH] git: show alias info only with lone -h

From
Jeff King <peff@peff.net>
Date
Jul 29, 2025, 07:26 UTC
Message-ID
<20250729072650.GD1426859@coredump.intra.peff.net>
In-Reply-To
<xmqqfregzb0r.fsf@gitster.g>
On Mon, Jul 28, 2025 at 06:43:16AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> > I guess one way to deal with it would be if the user runs "foo -h", and
> > alias.foo is "bar --other arguments", then we run just "bar -h",
> > dropping the extra arguments provided by the alias.
> 
> It is much simpler and saner to just stop after giving the alias
> expansion, isn't it?  Nobody can get hurt if we did so; doing
> anything else would be driving us into further corner cases that
> would either confuse or harm the users.

Yeah, my suggestion was assuming that it is very valuable for "git foo -h" to not only print out the alias but to automatically print git-bar's help output. I don't know if people would miss it or not.

But...
Show 18 quoted lines
> > I'd also be happy if on top we did:
> >
> >   1. When alias.foo="bar --options", turn "git foo -h" into "git bar
> >      -h", dropping "--options".
> 
> This smells like piling more voodoo magic on top, which I am not
> enthused.
> 
> >   2. When alias.foo="!bar", report only the alias and do not run "bar"
> >      at all. The collateral damage here would be:
> >
> >         !git bar $(some_shell_magic_we_need)
> >
> >      but IMHO that is not all that bad. If we report the alias content,
> >      the user can probably figure out which "git help" to run next.
> 
> This I very much like, and further, I would prefer to do this for
> all aliases.

...yeah, after having slept on it, I am tempted to say that it is not that valuable. And the best thing is to just stop running the sub-command automatically entirely, whether shell-based or not.

-Peff
Previous: Junio C Hamano
Message 9 of 9 in “-h prints alias information even for grep”
  1. Kevin BrodskyJul 25, 2025
  2. git: show alias info only with lone -hRené Scharfe, Jul 25, 2025
  3. Junio C HamanoJul 25, 2025
  4. Jeff KingJul 26, 2025
  5. D. Ben KnobleJul 26, 2025
  6. D. Ben KnobleJul 26, 2025
  7. Jeff KingJul 29, 2025
  8. Junio C HamanoJul 28, 2025
  9. Jeff KingJul 29, 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.