git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git merge auto-commit doesn't fire pre-commit hook
@ 2011-02-16 22:49 Liam Clarke
  2011-02-17  4:36 ` Jay Soffian
  0 siblings, 1 reply; 6+ messages in thread
From: Liam Clarke @ 2011-02-16 22:49 UTC (permalink / raw)
  To: git

Hi all, 

How exactly does git merge execute the commit? 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).

Regards, 

Liam Clarke

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git merge auto-commit doesn't fire pre-commit hook
  2011-02-16 22:49 git merge auto-commit doesn't fire pre-commit hook Liam Clarke
@ 2011-02-17  4:36 ` Jay Soffian
  2011-02-17  4:44   ` Liam Clarke
  0 siblings, 1 reply; 6+ messages in thread
From: Jay Soffian @ 2011-02-17  4:36 UTC (permalink / raw)
  To: Liam Clarke; +Cc: git

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git merge auto-commit doesn't fire pre-commit hook
  2011-02-17  4:36 ` Jay Soffian
@ 2011-02-17  4:44   ` Liam Clarke
  2011-02-17  4:48     ` Jay Soffian
  2011-02-17  4:52     ` Jay Soffian
  0 siblings, 2 replies; 6+ messages in thread
From: Liam Clarke @ 2011-02-17  4:44 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

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:

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git merge auto-commit doesn't fire pre-commit hook
  2011-02-17  4:44   ` Liam Clarke
@ 2011-02-17  4:48     ` Jay Soffian
  2011-02-17  4:52     ` Jay Soffian
  1 sibling, 0 replies; 6+ messages in thread
From: Jay Soffian @ 2011-02-17  4:48 UTC (permalink / raw)
  To: Liam Clarke; +Cc: git

On Wed, Feb 16, 2011 at 11:44 PM, Liam Clarke
<liam.clarke-hutchinson@adscale.co.nz> wrote:
> 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. :(

I agree. Note that the grandparent statement belongs to Junio, but he
also indicated at the end of the message that he didn't care too
deeply.

Personally, I think the commit hooks should fire whenever a commit is
made, regardless of the source. Maybe the hooks should move to the
low-level commit_tree, or maybe merge should invoke commit instead of
commit_tree.

j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git merge auto-commit doesn't fire pre-commit hook
  2011-02-17  4:44   ` Liam Clarke
  2011-02-17  4:48     ` Jay Soffian
@ 2011-02-17  4:52     ` Jay Soffian
  2011-02-17  5:05       ` Liam Clarke
  1 sibling, 1 reply; 6+ messages in thread
From: Jay Soffian @ 2011-02-17  4:52 UTC (permalink / raw)
  To: Liam Clarke; +Cc: git

On Wed, Feb 16, 2011 at 11:44 PM, Liam Clarke
<liam.clarke-hutchinson@adscale.co.nz> wrote:
> 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...

BTW, why not just use the post-merge hook to amend the merge after the fact?

j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git merge auto-commit doesn't fire pre-commit hook
  2011-02-17  4:52     ` Jay Soffian
@ 2011-02-17  5:05       ` Liam Clarke
  0 siblings, 0 replies; 6+ messages in thread
From: Liam Clarke @ 2011-02-17  5:05 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

It can't affect the merge, but I could check for the data's existence, rm it, commit the deletion, and then scold the naughty developer... Yeah, not a bad idea actually. :) Cheers Jay.

On 17/02/2011, at 5:52 PM, Jay Soffian wrote:

> On Wed, Feb 16, 2011 at 11:44 PM, Liam Clarke
> <liam.clarke-hutchinson@adscale.co.nz> wrote:
>> 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...
> 
> BTW, why not just use the post-merge hook to amend the merge after the fact?
> 
> j.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-17  5:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 22:49 git merge auto-commit doesn't fire pre-commit hook Liam Clarke
2011-02-17  4:36 ` Jay Soffian
2011-02-17  4:44   ` Liam Clarke
2011-02-17  4:48     ` Jay Soffian
2011-02-17  4:52     ` Jay Soffian
2011-02-17  5:05       ` Liam Clarke

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).