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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:07:49

Duy Nguyen [off-list ref] 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?

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

From: Duy Nguyen <hidden>
Date: 2016-06-15 23:07:49

On Wed, Jan 20, 2016 at 1:44 AM, Junio C Hamano [off-list ref] wrote:
Duy Nguyen [off-list ref] writes:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help