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

Re: git merge auto-commit doesn't fire pre-commit hook

From
LCLiam Clarke <liam.clarke-hutchinson@adscale.co.nz>
Date
Feb 17, 2011, 04:44 UTC
Message-ID
<6F190320-19AF-4F4A-9AE9-0DDA0839C5FD@adscale.co.nz>
In-Reply-To
<AANLkTimCdQL879kBZiktB49eSvoAGT0pX5DKX0SHFOVB@mail.gmail.com>
Cheers Jay.
> The bypassing of pre-commit hook was and remains to be a conscious design
decision.  
That doesn't sound good for my purposes. It also renders Git merge behaviour significantly surprising. :(
>  When you are pulling from your contributors who may have

objectionable contents that you have to merge, the damage is already done; you _could_ yell at them to fix their branch and re-pull in theory, but that wouldn't work very well in practice.

What about when I'm merging my own feature branches into master? Also, past performance indicates that yelling about bad stuff in merges works quite well when they're in the same office as you... 
...but anyway, thanks for the heads up Jay. 
On 17/02/2011, at 5:36 PM, Jay Soffian wrote:
Show 18 quoted lines
> On Wed, Feb 16, 2011 at 5:49 PM, Liam Clarke
> <liam.clarke-hutchinson@adscale.co.nz> wrote:
>> How exactly does git merge execute the commit?
> 
> Merge calls commit_tree directly, so the standard commit hooks are bypassed.
> 
>> Does it use --no-verify at all? I've got a pre-commit hook to filter out testing data when merging into master, and if you merge with --no-commit, and then manually commit, the hook fires fine, but when merge autocommits, the hook doesn't get executed at all. Is there any other way to catch this event? I can add --no-commit to the branch.master.mergeoptions I suppose, but I don't want to add too much hassle for our Git users (if they're not checking in test data, of course).
> 
> I recently fixed this for prepare-commit-msg since that was the one I
> cared about. See
> http://thread.gmane.org/gmane.comp.version-control.git/151297 and
> http://thread.gmane.org/gmane.comp.version-control.git/166805
> 
> j.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Jay SoffianNext: Jay Soffian
Message 3 of 6 in “git merge auto-commit doesn't fire pre-commit hook”
  1. Liam ClarkeFeb 16, 2011
  2. Jay SoffianFeb 17, 2011
  3. Liam ClarkeFeb 17, 2011
  4. Jay SoffianFeb 17, 2011
  5. Jay SoffianFeb 17, 2011
  6. Liam ClarkeFeb 17, 2011

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.