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

Re: Adding custom hooks to a bare repository.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 28, 2008, 12:40 UTC
Message-ID
<alpine.DEB.1.00.0807281438220.2725@eeepc-johanness>
In-Reply-To
<18071eea0807280532l69d12e3ehb8377da9d24e035@mail.gmail.com>
Hi,
On Mon, 28 Jul 2008, Thomas Adam wrote:
Show 19 quoted lines
> 2008/7/28 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
>
> > Yes.  Hooks, just as the config and reflogs, are supposed to be local 
> > things.  Rationale being: it is rude, and also insecure, to install 
> > something that potentially calls other programs without the user 
> > saying so.
> 
> Oh absolutely, I agree with that.
> 
> > All you can do is checking in a copy of the hook, and ask your 
> > users/check in your build system that it is installed.
> 
> Hmm -- perhaps I am being unintentionally dense, but I am assuming
> that when you say "checking in a copy" you mean anywhere other than
> .git/hooks/ since that isn't tracked by git.  I have no problem with
> the rationale you've just described -- but it would be handy to add
> this post-merge hook script into hooks/ (exec bit removed) such that
> on a clone, all one would need to do is chmod +x it.   If that's
> possible, I'm clearly missing the steps to enable this.

No, as you said, anything in .git/ is not meant to be tracked. Besides, if a user would change the executable bit (as advised), Git would always show this file as modified, making the tree permanently dirty (or worse, it could be accidentally be committed as executable).

For all those reasons, it is better to just commit an executable script in your <toplevel>/githooks/post-merge and ask your users to copy it to .git/hooks/.

Hth, Dscho

Previous: Thomas AdamNext: Thomas Adam
Message 4 of 5 in “Adding custom hooks to a bare repository.”
  1. Thomas AdamJul 28, 2008
  2. Johannes SchindelinJul 28, 2008
  3. Thomas AdamJul 28, 2008
  4. Johannes SchindelinJul 28, 2008
  5. Thomas AdamJul 28, 2008

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.