{"thread":{"id":"26526","subject":"git merge auto-commit doesn't fire pre-commit hook","startedAt":"2011-02-16T22:49:43Z","lastAt":"2011-02-17T05:05:25Z","messageCount":6,"participants":["Liam Clarke","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"161353","messageId":"1F3B7FF9-6348-4197-A6B7-23C4DA144920@adscale.co.nz","threadId":"26526","inReplyTo":null,"subject":"git merge auto-commit doesn't fire pre-commit hook","fromName":"Liam Clarke","fromEmail":"liam.clarke-hutchinson@adscale.co.nz","sentAt":"2011-02-16T22:49:43Z","receivedAt":"2011-02-16T22:49:43Z","isPatch":false,"sender":{"key":"liam.clarke-hutchinson@adscale.co.nz","avatar":null},"body":"Hi all, \n\nHow 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).\n\nRegards, \n\nLiam Clarke"},{"id":"161372","messageId":"AANLkTimCdQL879kBZiktB49eSvoAGT0pX5DKX0SHFOVB@mail.gmail.com","threadId":"26526","inReplyTo":"1F3B7FF9-6348-4197-A6B7-23C4DA144920@adscale.co.nz","subject":"Re: git merge auto-commit doesn't fire pre-commit hook","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-02-17T04:36:09Z","receivedAt":"2011-02-17T04:36:09Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 16, 2011 at 5:49 PM, Liam Clarke\n<liam.clarke-hutchinson@adscale.co.nz> wrote:\n> How exactly does git merge execute the commit?\n\nMerge calls commit_tree directly, so the standard commit hooks are bypassed.\n\n>  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).\n\nI recently fixed this for prepare-commit-msg since that was the one I\ncared about. See\nhttp://thread.gmane.org/gmane.comp.version-control.git/151297 and\nhttp://thread.gmane.org/gmane.comp.version-control.git/166805\n\nj.\n"},{"id":"161373","messageId":"6F190320-19AF-4F4A-9AE9-0DDA0839C5FD@adscale.co.nz","threadId":"26526","inReplyTo":"AANLkTimCdQL879kBZiktB49eSvoAGT0pX5DKX0SHFOVB@mail.gmail.com","subject":"Re: git merge auto-commit doesn't fire pre-commit hook","fromName":"Liam Clarke","fromEmail":"liam.clarke-hutchinson@adscale.co.nz","sentAt":"2011-02-17T04:44:43Z","receivedAt":"2011-02-17T04:44:43Z","isPatch":false,"sender":{"key":"liam.clarke-hutchinson@adscale.co.nz","avatar":null},"body":"Cheers Jay.\n\n> The bypassing of pre-commit hook was and remains to be a conscious design\ndecision.  \n\nThat doesn't sound good for my purposes. It also renders Git merge behaviour significantly surprising. :(\n\n>  When you are pulling from your contributors who may have\nobjectionable contents that you have to merge, the damage is already\ndone; you _could_ yell at them to fix their branch and re-pull in theory,\nbut that wouldn't work very well in practice.\n\nWhat 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... \n\n...but anyway, thanks for the heads up Jay. \n\nOn 17/02/2011, at 5:36 PM, Jay Soffian wrote:\n\n> On Wed, Feb 16, 2011 at 5:49 PM, Liam Clarke\n> <liam.clarke-hutchinson@adscale.co.nz> wrote:\n>> How exactly does git merge execute the commit?\n> \n> Merge calls commit_tree directly, so the standard commit hooks are bypassed.\n> \n>> 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).\n> \n> I recently fixed this for prepare-commit-msg since that was the one I\n> cared about. See\n> http://thread.gmane.org/gmane.comp.version-control.git/151297 and\n> http://thread.gmane.org/gmane.comp.version-control.git/166805\n> \n> j.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"161374","messageId":"AANLkTi=DF6HiMcKA5r_HMTD3roneGZdfqFKZ_sYCy1wG@mail.gmail.com","threadId":"26526","inReplyTo":"6F190320-19AF-4F4A-9AE9-0DDA0839C5FD@adscale.co.nz","subject":"Re: git merge auto-commit doesn't fire pre-commit hook","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-02-17T04:48:46Z","receivedAt":"2011-02-17T04:48:46Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 16, 2011 at 11:44 PM, Liam Clarke\n<liam.clarke-hutchinson@adscale.co.nz> wrote:\n> Cheers Jay.\n>\n>> The bypassing of pre-commit hook was and remains to be a conscious design\n> decision.\n>\n> That doesn't sound good for my purposes. It also renders Git merge behaviour significantly surprising. :(\n\nI agree. Note that the grandparent statement belongs to Junio, but he\nalso indicated at the end of the message that he didn't care too\ndeeply.\n\nPersonally, I think the commit hooks should fire whenever a commit is\nmade, regardless of the source. Maybe the hooks should move to the\nlow-level commit_tree, or maybe merge should invoke commit instead of\ncommit_tree.\n\nj.\n"},{"id":"161375","messageId":"AANLkTim+_s5S46QwhHLquMLsoqCwLASdyeW1Lu6md=TB@mail.gmail.com","threadId":"26526","inReplyTo":"6F190320-19AF-4F4A-9AE9-0DDA0839C5FD@adscale.co.nz","subject":"Re: git merge auto-commit doesn't fire pre-commit hook","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-02-17T04:52:47Z","receivedAt":"2011-02-17T04:52:47Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 16, 2011 at 11:44 PM, Liam Clarke\n<liam.clarke-hutchinson@adscale.co.nz> wrote:\n> 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...\n\nBTW, why not just use the post-merge hook to amend the merge after the fact?\n\nj.\n"},{"id":"161376","messageId":"542F1586-F49F-4CD4-A15A-0C7002EB8CE1@adscale.co.nz","threadId":"26526","inReplyTo":"AANLkTim+_s5S46QwhHLquMLsoqCwLASdyeW1Lu6md=TB@mail.gmail.com","subject":"Re: git merge auto-commit doesn't fire pre-commit hook","fromName":"Liam Clarke","fromEmail":"liam.clarke-hutchinson@adscale.co.nz","sentAt":"2011-02-17T05:05:25Z","receivedAt":"2011-02-17T05:05:25Z","isPatch":false,"sender":{"key":"liam.clarke-hutchinson@adscale.co.nz","avatar":null},"body":"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.\n\nOn 17/02/2011, at 5:52 PM, Jay Soffian wrote:\n\n> On Wed, Feb 16, 2011 at 11:44 PM, Liam Clarke\n> <liam.clarke-hutchinson@adscale.co.nz> wrote:\n>> 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...\n> \n> BTW, why not just use the post-merge hook to amend the merge after the fact?\n> \n> j.\n"}]}