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

Re: Issue when changing staged files in a pre-commit hook

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 19, 2016, 23:26 UTC
Message-ID
<CACsJy8DxQnGV5JZnHuvA1Zbpf2BuGdmMF+YNiq51HNK+8vW56Q@mail.gmail.com>
In-Reply-To
<xmqq1t9dbe9y.fsf@gitster.mtv.corp.google.com>
On Wed, Jan 20, 2016 at 1:44 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> I think it's the intended behavior.
>
> Yeah, pre-commit was designed for inspecting and rejecting, not for
> tweaking and munging.  Perhaps "git commit" can be tightened to make
> sure that pre-commit that returns successfully did not muck with the
> working tree and the index?
That was my impression from the docs, but then I saw this comment,
/*
* Re-read the index as pre-commit hook could have updated it,
* and write it out as a tree.  We must do this before we invoke
* the editor and after we invoke run_status above.
*/

which comes from 2888605 (builtin-commit: fix partial-commit support - 2007-11-18) that admits "the hook can modify it (the index)". And I was about to update the docs, but the other way around, about updating index and side effects.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 9 in “Issue when changing staged files in a pre-commit hook”
  1. Niek van der KooyDec 28, 2015
  2. Niek van der KooyJan 19, 2016
  3. Duy NguyenJan 19, 2016
  4. Junio C HamanoJan 19, 2016
  5. Duy NguyenJan 19, 2016
  6. Junio C HamanoJan 19, 2016
  7. Duy NguyenJan 20, 2016
  8. Junio C HamanoJan 20, 2016
  9. Duy NguyenJan 22, 2016

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.