# multiple files for the same hook

6 messages from 2008-05-12 to 2008-05-13. Participants: Thomas Hunger, Sverre Rabbelier, Miklos Vajna, Jeff King, Martin Langhoff.
Thread: https://gitlist.dev/t/13497

## Thomas Hunger, 2008-05-12 20:39

Subject: multiple files for the same hook
Message-ID: <200805122039.49779.hto@arcor.de>
URL: https://gitlist.dev/e/200805122039.49779.hto%40arcor.de

```
Hi,

we use hooks a lot for various cleanup tasks, tests and warnings. It 
would be wonderful if we could keep the hook logic in separate files. 

Something like

    hooks/post-commit.d/

where all executable files in the dir are executed in alphanumeric 
order. Is there a possibility of this going into git (I could try a 
patch)?

Tom

```

## Sverre Rabbelier, 2008-05-12 20:43

Subject: Re: multiple files for the same hook
Message-ID: <bd6139dc0805121343i71fc99ebr6570044ddc0ba287@mail.gmail.com>
URL: https://gitlist.dev/e/bd6139dc0805121343i71fc99ebr6570044ddc0ba287%40mail.gmail.com
In-Reply-To: <200805122039.49779.hto@arcor.de>

```
On Mon, May 12, 2008 at 10:39 PM, Thomas Hunger <hto@arcor.de> wrote:
>  where all executable files in the dir are executed in alphanumeric
>  order. Is there a possibility of this going into git (I could try a
>  patch)?

Heya,

Wouldn't it be easy to have the hook script do that?
Just have it walk through the directory and call all the scripts?

-- 
Cheers,

Sverre Rabbelier

```

## Miklos Vajna, 2008-05-12 20:44

Subject: Re: multiple files for the same hook
Message-ID: <20080512204445.GT27724@genesis.frugalware.org>
URL: https://gitlist.dev/e/20080512204445.GT27724%40genesis.frugalware.org
In-Reply-To: <200805122039.49779.hto@arcor.de>

```
On Mon, May 12, 2008 at 08:39:49PM +0000, Thomas Hunger <hto@arcor.de> wrote:
> we use hooks a lot for various cleanup tasks, tests and warnings. It 
> would be wonderful if we could keep the hook logic in separate files. 
> 
> Something like
> 
>     hooks/post-commit.d/
> 
> where all executable files in the dir are executed in alphanumeric 
> order. Is there a possibility of this going into git (I could try a 
> patch)?

why would you want so? just create a script named hooks/post-commit,
like:

----
#!/bin/sh
/path/to/first/script
/path/to/second/script
----

or so.

it's not something git should do for you.

```

## Thomas Hunger, 2008-05-12 21:56

Subject: Re: multiple files for the same hook
Message-ID: <200805122156.30896.hto@arcor.de>
URL: https://gitlist.dev/e/200805122156.30896.hto%40arcor.de
In-Reply-To: <20080512204445.GT27724@genesis.frugalware.org>

```
Miklos, Sverre,

> why would you want so? just create a script named
> hooks/post-commit, like:

you are right, it's what we actually do, using --template to set up 
our own scripts. If nobody but us needs this it's certainly not worth 
bothering.

Thanks
Tom

```

## Jeff King, 2008-05-13 04:21

Subject: Re: multiple files for the same hook
Message-ID: <20080513042118.GB4079@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20080513042118.GB4079%40sigill.intra.peff.net
In-Reply-To: <200805122156.30896.hto@arcor.de>

```
On Mon, May 12, 2008 at 09:56:30PM +0000, Thomas Hunger wrote:

> > why would you want so? just create a script named
> > hooks/post-commit, like:
> 
> you are right, it's what we actually do, using --template to set up 
> our own scripts. If nobody but us needs this it's certainly not worth 
> bothering.

The problem is that the semantics of calling some of the hooks is not as
simple as just calling them all in a row. How do you split up the input
going to the hooks? How do you combine the output coming from the hooks?
What is the resulting exit code? If one hook fails, do we indicate
failure? Or if one hook succeeds, do we indicate success?

So before any such code could go into git proper, there would have to be
agreement on how those issues are resolved. In the meantime, it probably
makes more sense to implement a "master" post-commit hook that uses the
semantics that you find useful.

-Peff

```

## Martin Langhoff, 2008-05-13 08:05

Subject: Re: multiple files for the same hook
Message-ID: <46a038f90805130105p67fa2081p2537db29305a6231@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90805130105p67fa2081p2537db29305a6231%40mail.gmail.com
In-Reply-To: <20080513042118.GB4079@sigill.intra.peff.net>

```
On Tue, May 13, 2008 at 4:21 PM, Jeff King <peff@peff.net> wrote:
>  In the meantime, it probably
>  makes more sense to implement a "master" post-commit hook that uses the
>  semantics that you find useful.

And when you are implementing those semantics, you might be able to
reuse "run-parts" which does roughly what you want.

:-)

cheers,



m
--
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

```
