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

Re: Interaction between pre-commit hook and git commit <pathspec>

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 3, 2026, 20:38 UTC
Message-ID
<xmqqmrrp646a.fsf@gitster.g>
In-Reply-To
<de4f4f35-500f-4d82-acfd-ca601444f2d2@app.fastmail.com>
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
> Reading githooks documentation for pre-commit. To me it reads like
> the use case is validation/checking, not any mutation.

Yes, the hook was written exactly for validation, to preempt an undesirable commit from being created.

We might want to do two things:
(1) clarify the documentation to say that the hook should not try
    mutation, and
(2) detect and error out when the hook does try to make any
    mutation.
I am not sure if (2) is feasible, though.
Thanks.
Previous: Kristoffer HaugsbakkNext: Chris Torek
Message 3 of 4 in “Interaction between pre-commit hook and git commit <pathspec>”
  1. Kevin LylesNov 3, 2026
  2. Kristoffer HaugsbakkNov 3, 2026
  3. Junio C HamanoNov 3, 2026
  4. Chris TorekNov 3, 2026

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.