threads / discuss / 15849

merge hook

Subject: merge hook

## tl;dr

4 messages between Oct 10, 2008 and Oct 10, 2008.

replies: 3people: 2as markdown or json

Erik Colson· Oct 10, 2008, 07:21 UTC · lore
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· Oct 10, 2008, 10:07 UTC · re: Erik Colson · lore

Re: merge hook

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· Oct 10, 2008, 10:26 UTC · re: Johannes Schindelin · lore

Re: merge hook

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· Oct 10, 2008, 12:30 UTC · re: Erik Colson · lore

Re: merge hook

Hi,
On Fri, 10 Oct 2008, Erik Colson wrote:
Show 9 quoted lines
> 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

← back to recent threads