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

Re: global hooks - once again

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 2, 2010, 20:53 UTC
Message-ID
<20100702205348.GA8134@burratino>
In-Reply-To
<7v630x1yl8.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
Show 5 quoted lines
> Now, as long as the "do once per repository" action that you need to do is
> simple enough, it doesn't necessarily have to be "git config".  Perhaps
> 
>     [alias]
>     set-hooks = !"sh -c 'rm -fr .git/hooks && ln -s $1 .git/hooks' -"

It is not difficult to set up hook scripts when initializing a repository. In fact git clone --template= and the “[init] templatedir” configuration work pretty well. What is more difficult is to change the list of hook scripts later.

If I symlink the entire hooks dir like you describe, I cannot override a couple of hooks per-repository without teaching the hook scripts to handle that themselves. (something like:

	hook=$(basename "$0")
	! test -e "$GIT_DIR/local-hooks/$hook.disable" || exit 0
	! test -e "$GIT_DIR/local-hooks/$hook" ||
		exec "$GIT_DIR/local-hooks/$hook"
)  Maybe that is the simplest solution.
Previous: demerphq
Message 14 of 14 in “global hooks - once again”
  1. Eugene SajineJul 2, 2010
  2. Jonathan NiederJul 2, 2010
  3. Eugene SajineJul 2, 2010
  4. Junio C HamanoJul 2, 2010
  5. Eugene SajineJul 2, 2010
  6. Peter KjellerstedtJul 5, 2010
  7. Alex RiesenJul 6, 2010
  8. Eugene SajineJul 6, 2010
  9. Peter KjellerstedtJul 6, 2010
  10. demerphqJul 6, 2010
  11. Eugene SajineJul 6, 2010
  12. Eugene SajineJul 6, 2010
  13. demerphqJul 6, 2010
  14. Jonathan NiederJul 2, 2010

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.