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

Re: [PATCH v4] add: support pre-add hook

From
Adrian Ratiu <adrian.ratiu@collabora.com>
Date
Mar 5, 2026, 12:03 UTC
Message-ID
<87seaexz33.fsf@gentoo.mail-host-address-is-not-set>
In-Reply-To
<pull.2045.v4.git.1772710566599.gitgitgadget@gmail.com>
Hi Chandra,
On Thu, 05 Mar 2026, "Chandra Kethi-Reddy via GitGitGadget" <gitgitgadget@gmail.com> wrote:
Show 9 quoted lines
> @@ -576,6 +582,11 @@ int cmd_add(int argc,
>  		string_list_clear(&only_match_skip_worktree, 0);
>  	}
>  
> +	if (!show_only && !no_verify && find_hook(repo, "pre-add")) {
> +		run_pre_add = 1;
> +		orig_index_path = absolute_pathdup(repo_get_index_file(repo));
> +	}
> +

Please use hook_exists() instead of find_hook() because that works with hooks defined via config files. Otherwise your hooks API usage is great.

Maybe add a test or two which define the pre-add hook via configs to verify it works?

(regarding find_hook(), we sholud mark it as deprecated or convert all its remaining uses and remove it, however that's outside the scope of your series, no worries)

Previous: Chandra Kethi-Reddy via GitGitGadgetNext: Chandra
Message 18 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. RE: add: support pre-add hookChandra, Feb 11, 2026
  5. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, 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, Mar 5, 2026
  16. Junio C HamanoMar 5, 2026
  17. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Mar 5, 2026
  18. Adrian RatiuMar 5, 2026
  19. ChandraMar 5, 2026
  20. add: support pre-add hookChandra Kethi-Reddy via GitGitGadget, Mar 5, 2026
  21. Adrian RatiuMar 5, 2026
  22. ChandraMar 5, 2026
  23. Junio C HamanoMar 5, 2026
  24. ChandraMar 6, 2026
  25. Phillip WoodMar 13, 2026
  26. Phillip WoodMar 5, 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.