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

Re: What about allowing multiple hooks?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 21, 2009, 21:10 UTC
Message-ID
<alpine.DEB.1.00.0901212206430.3586@pacific.mpi-cbg.de>
In-Reply-To
<4977872E.70901@0x63.nu>
Hi,
On Wed, 21 Jan 2009, Anders Waldenborg wrote:
Show 12 quoted lines
> I need multiple hooks, so I've done some thinking about this, so I 
> thought it may be a good idea to share this here.
> 
> I currently use configvalues to specify which hooks to run. For example 
> this is how my post-receive looks:
> 
> data=$(cat)
> git config --get-all hooks.post-receive.hook | while read hook; do
>         $hook <<__EOF__
> "$data"
> __EOF__
> done
I wonder why you don't do the obvious thing:
	data=$(cat)
	for hook in .git/hooks/update.d/*
	do
		test -x "$hook" || continue
		echo "$data" | "$hook" | exit
	done

and then name the hooks in your .git/hooks/update.d/ with leading zero-padded numbers so that you guarantee a certain order.

You can even share special hooks between repositories by symlinking, as is done in /etc/init.d/rc?.d.

Hth, Dscho

P.S.: If you want to save even more interactive work, you can name the hooks .git/hooks/update.[0-9]*.

Previous: Anders WaldenborgNext: Anders Waldenborg
Message 7 of 10 in “What about allowing multiple hooks?”
  1. Marc WeberNov 21, 2008
  2. martin f krafftNov 21, 2008
  3. Rogan DawesNov 21, 2008
  4. Alexander PotashevJan 3, 2009
  5. Junio C HamanoJan 4, 2009
  6. Anders WaldenborgJan 21, 2009
  7. Johannes SchindelinJan 21, 2009
  8. Anders WaldenborgJan 21, 2009
  9. Johannes SchindelinJan 21, 2009
  10. Anders WaldenborgJan 22, 2009

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.