Re: [PATCH v3] add: support pre-add hook
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 5, 2026, 14:48 UTC
- Message-ID
- <87h5qujps7.fsf@gitster.g>
- In-Reply-To
- <27ee9a9c-0caa-4b6e-a968-51c71c8b6e5f@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 6 quoted lines
> paths that are staged by the current invocation of "git add". That means > if for some reason I need to bypass the hook when running "git add" I'll > have to bypass it every time until I commit and cannot check the other > changes that I'm staging. It also means that running "git add" several > times, each with a different path runs the hook multiple times on the > same content.
Correct. You'd need "git diff --name-only HEAD" twice and run the results through "comm -13" or something.
Show 7 quoted lines
> These caveats are rather unfortunate as it means to be sure that staged > changes get checked I have to duplicate the "pre-add" checks in the > "pre-commit" hook which is rather inefficient. It would be very nice to > be able to check changes as they're staged rather than just before they > are committed but I can't help feeling that what's proposed here is > driven by ease of implementation which leads to a rather incoherent user > experience.
True.
As I already said, I am not sure of the value of the proposed hook.
Thanks.