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

Re: is it kosher for pre-commit to change what's staged?

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 10, 2010, 19:57 UTC
Message-ID
<7v1v6thrzc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20101110170819.GA3031@gnu.kitenet.net>
Joey Hess <joey@kitenet.net> writes:
Show 5 quoted lines
> I've noticed that if I make a pre-commit hook change the files that are
> staged, those changes are not reflected in the commit message. For
> example, if a pre-commit hook git add's somefile, the commit message
> won't reflect that. I guess prepare-commit-msg is being run before
> pre-commit for some reason?

My intention was that Documentation/githooks.txt would document things that are allowed (e.g. "applypatch-msg" explicitly says "The hook is allowed to edit the message"), and anything that is not specifically allowed is not.

"Is it kosher" is a difficult question to answer, as something may not be allowed but there may not be an enforcement mechanism to deny it, iow, it may happen to work by accident.

In general, pre-anything is about checking and denying and is supposed to be free of side effects.

Previous: Joey HessNext: Jonathan Nieder
Message 2 of 9 in “is it kosher for pre-commit to change what's staged?”
  1. Joey HessNov 10, 2010
  2. Junio C HamanoNov 10, 2010
  3. Jonathan NiederNov 10, 2010
  4. Joey HessNov 10, 2010
  5. Dmitry PotapovNov 10, 2010
  6. Jan HudecNov 11, 2010
  7. Joey HessNov 11, 2010
  8. Junio C HamanoNov 11, 2010
  9. Kevin BallardNov 11, 2010

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.