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

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.
Previous: Phillip WoodNext: Junio C Hamano
Message 23 of 26 in “add: support pre-add hook”
  1. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Feb 10, 2026
  2. Junio C HamanoFeb 10, 2026
  3. Junio C HamanoFeb 10, 2026
  4. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Feb 11, 2026
  5. RE: add: support pre-add hookChandra, Feb 11, 2026
  6. Junio C HamanoFeb 11, 2026
  7. ChandraFeb 11, 2026
  8. Junio C HamanoFeb 11, 2026
  9. ChandraFeb 11, 2026
  10. ChandraFeb 25, 2026
  11. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Feb 27, 2026
  12. Junio C HamanoMar 3, 2026
  13. Ben KnobleMar 4, 2026
  14. Phillip WoodMar 5, 2026
  15. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Mar 5, 2026
  16. add: support pre-add hookChandra, Mar 5, 2026
  17. Adrian RatiuMar 5, 2026
  18. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Mar 5, 2026
  19. ChandraMar 5, 2026
  20. Adrian RatiuMar 5, 2026
  21. ChandraMar 5, 2026
  22. Phillip WoodMar 5, 2026
  23. Junio C HamanoMar 5, 2026
  24. Junio C HamanoMar 5, 2026
  25. ChandraMar 6, 2026
  26. Phillip WoodMar 13, 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.