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

Re: [PATCH] git: run alias subprocess according to the API

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 15, 2025, 19:09 UTC
Message-ID
<xmqq7bxzh6sl.fsf@gitster.g>
In-Reply-To
<20250915180842.GA642496@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 16 quoted lines
> I'm not sure there _is_ any reason to use a raw "git" instead of
> ".git_cmd". The case in upload-pack is _not_ running a git command
> directly. It is passing the name of a git command to the hook. So you
> end up running:
>
>   /path/to/my/hook git pack-objects ...args...
>
> So I don't think there is any X or Y, and the rule can just be "you
> should use .git_cmd".
> ...
> That said, I do not think it is particularly important to use .git_cmd;
> it really is just prepending "git" to argv. It does also override
> .use_shell, but it is nonsense to set both flags in the first place
> (which is something we could perhaps flag with a BUG() if we cared to).
> But I have no problem with preferring .git_cmd to "git" as a style
> preference.

Ah, OK. I just was confused by the explanation in the middle that appeared to be saying that they are not truly equivalent. If not, then I am perfectly fine.

I would actually prefer to get rid of the .git_cmd member altogether to make it simpler to code. The run_command() function should be able to internally decide to short-circuit and invoke "git" directly without the shell by looking at the first element of the argv[] array, One less thing for human programmers to worry about.

Previous: Jeff KingNext: Jeff King
Message 4 of 5 in “git: run alias subprocess according to the API”
  1. git: run alias subprocess according to the APIkristofferhaugsbakk@fastmail.com, Sep 14, 2025
  2. Junio C HamanoSep 15, 2025
  3. Jeff KingSep 15, 2025
  4. Junio C HamanoSep 15, 2025
  5. Jeff KingSep 15, 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.