# merge hook

4 messages from 2008-10-10 to 2008-10-10. Participants: Erik Colson, Johannes Schindelin.
Thread: https://gitlist.dev/t/15849

## Erik Colson, 2008-10-10 07:21

Subject: merge hook
Message-ID: <20081010072148.GB303@Mac2.local>
URL: https://gitlist.dev/e/20081010072148.GB303%40Mac2.local

```
Hello,

Is it possible to launch a custom script on all files involved in a
merge to master ? 
If yes, is it then also possible to reject the merge if the script
returns an error ?

Thanks
--
Erik

```

## Johannes Schindelin, 2008-10-10 10:07

Subject: Re: merge hook
Message-ID: <alpine.DEB.1.00.0810101204540.22125@pacific.mpi-cbg.de.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0810101204540.22125%40pacific.mpi-cbg.de.mpi-cbg.de
In-Reply-To: <20081010072148.GB303@Mac2.local>

```
Hi,

On Fri, 10 Oct 2008, Erik Colson wrote:

> Is it possible to launch a custom script on all files involved in a 
> merge to master ? If yes, is it then also possible to reject the merge 
> if the script returns an error ?

>From Documentation/githooks.txt:

-- snip --
prepare-commit-msg
------------------

This hook is invoked by 'git-commit' right after preparing the
default log message, and before the editor is started.

It takes one to three parameters.  The first is the name of the file that 
the commit log message.  The second is the source of the commit message, 
and can be: [...] `merge` (if the commit is a merge or a `.git/MERGE_MSG` 
file exists); [...]

If the exit status is non-zero, 'git-commit' will abort.
-- snap --

To see which files are affected, you'd just need to ask "git diff 
--name-only --cached".

I guess that you want to disallow merging in changes from people who 
changed files that are none of their business?  If so, it would be nice to 
contribute the hook as a patch to contrib/.

Ciao,
Dscho

```

## Erik Colson, 2008-10-10 10:26

Subject: Re: merge hook
Message-ID: <20081010102603.GC303@Mac2.local>
URL: https://gitlist.dev/e/20081010102603.GC303%40Mac2.local
In-Reply-To: <alpine.DEB.1.00.0810101204540.22125@pacific.mpi-cbg.de.mpi-cbg.de>

```
On Fri, Oct 10, 2008 at 12:07:16PM +0200, Johannes Schindelin wrote:

[..]

> From Documentation/githooks.txt:

thank you for pointing me there

[..]

> I guess that you want to disallow merging in changes from people who 
> changed files that are none of their business?  If so, it would be nice to 
> contribute the hook as a patch to contrib/.

wrong guess ;)
The purpose is to check if source code still has debug code in
it. Our policy is to have it removed before reaching master, but
checking by hand is way too buggy ;)

--
erik

```

## Johannes Schindelin, 2008-10-10 12:30

Subject: Re: merge hook
Message-ID: <alpine.DEB.1.00.0810101429280.22125@pacific.mpi-cbg.de.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0810101429280.22125%40pacific.mpi-cbg.de.mpi-cbg.de
In-Reply-To: <20081010102603.GC303@Mac2.local>

```
Hi,

On Fri, 10 Oct 2008, Erik Colson wrote:

> On Fri, Oct 10, 2008 at 12:07:16PM +0200, Johannes Schindelin wrote:
> 
> > I guess that you want to disallow merging in changes from people who 
> > changed files that are none of their business?  If so, it would be 
> > nice to contribute the hook as a patch to contrib/.
> 
> wrong guess ;) The purpose is to check if source code still has debug 
> code in it. Our policy is to have it removed before reaching master, but 
> checking by hand is way too buggy ;)

Heh.  Still, if it is not too specific, would be nice to have it in 
contrib/.  So I can point other people to it ;-)

Ciao,
Dscho

```
