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

Re: Commit f5bbc322 to git broke pre-commit hooks which read stdin

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 4, 2008, 12:17 UTC
Message-ID
<7vbq5u7kf9.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<47CD370A.3070404@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 9 quoted lines
>> It is not metastore.  It is an interactive hook that reads from the user
>> who is sitting on the terminal and invoked the git-commit program.
>
> Are you saying stdin should not be directed to /dev/null, or that an
> interactive hook is required to do
>
>     exec < /dev/tty || { echo 2>&1 "not interactive"; exit 1; }
>
> before it reads from stdin?

I am saying that scripted version left the stdin as-is but somehow we ended up spawning with .no_stdin = 1 in the C-rewrite, which is a change in established behaviour. It is often called a regression, unless the change has a very good reason. And I tend to think this particular one falls into the former.

We should audit how the hooks are called from various commands re-implemented, comparing the environment the scripted version used to give them, which includes:

 - what directory the hook is run in;
 - what environment variables are exported to it;
 - what temporary files are visible to them for inspection;
 - in what order they are run;
 - which file descriptor is connected to what;

I think we already caught some of the environment and ordering issues in commit and checkout, but I am far from confident to say that what we have behave identically to the scripted version.

Previous: Johannes SixtNext: David Bremner
Message 5 of 14 in “Bug#469250: Commit f5bbc322 to git broke pre-commit hooks which read stdin”
  1. David BremnerMar 4, 2008
  2. Johannes SchindelinMar 4, 2008
  3. Junio C HamanoMar 4, 2008
  4. Johannes SixtMar 4, 2008
  5. Junio C HamanoMar 4, 2008
  6. David BremnerMar 4, 2008
  7. Johannes SchindelinMar 4, 2008
  8. Joey HessMar 4, 2008
  9. David BremnerMar 4, 2008
  10. Shawn O. PearceMar 5, 2008
  11. Junio C HamanoMar 5, 2008
  12. Shawn O. PearceMar 5, 2008
  13. Jakub NarebskiMar 4, 2008
  14. Johannes SchindelinMar 4, 2008

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.