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

Re: merge hook

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 10, 2008, 10:07 UTC
Message-ID
<alpine.DEB.1.00.0810101204540.22125@pacific.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

Previous: Erik ColsonNext: Erik Colson
Message 2 of 4 in “merge hook”
  1. Erik ColsonOct 10, 2008
  2. Johannes SchindelinOct 10, 2008
  3. Erik ColsonOct 10, 2008
  4. Johannes SchindelinOct 10, 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.