Subject: Re: [PATCH v3] add: support pre-add hook

From: Junio C Hamano <[email-masked]>
Date: Thu, 05 Mar 2026 06:48:24 -0800

Phillip Wood <[email-masked]> writes:

> 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.

> 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.