{"thread":{"id":"46735","subject":"commit-msg hook does not run on merge with --no-ff option","startedAt":"2017-09-11T14:34:11Z","lastAt":"2017-09-20T20:09:12Z","messageCount":7,"participants":["Joseph Dunne","Stefan Beller","Kaartic Sivaraam","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"327850","messageId":"CAC7pkbQhwLFQQjqBwaW=0j4iKFcLdKDucCMck-PsSAeCs0rqpw@mail.gmail.com","threadId":"46735","inReplyTo":null,"subject":"commit-msg hook does not run on merge with --no-ff option","fromName":"Joseph Dunne","fromEmail":"jdunne525@gmail.com","sentAt":"2017-09-11T14:34:06Z","receivedAt":"2017-09-11T14:34:11Z","isPatch":false,"sender":{"key":"jdunne525@gmail.com","avatar":null},"body":"I’ve globally configured git master branch to use the –no-ff option in\nmy .gitconfig file:\n[branch \"master\"]\n                mergeoptions = “-–no-ff”\n\nWhen I merge a branch into master that would normally be a fast\nforward merge, the merge happens fine and follows the option –no-ff,\ncreating a new commit, however my commit-msg hook does not run.  (The\ncommit-msg hook works fine in all other commits / merges.)\n\nI tried changing my commit-msg hook to just be “exit 1” and it doesn’t\nabort a no-ff merge, so I’m certain the hook is just not being\nexecuted.\n"},{"id":"327853","messageId":"CAGZ79kZLvAgSgckQ7Doo_E7aY+L6xtv2Kq0xbO6GSZL5ZAb7TQ@mail.gmail.com","threadId":"46735","inReplyTo":"CAC7pkbQhwLFQQjqBwaW=0j4iKFcLdKDucCMck-PsSAeCs0rqpw@mail.gmail.com","subject":"Re: commit-msg hook does not run on merge with --no-ff option","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-09-11T17:25:38Z","receivedAt":"2017-09-11T17:25:44Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Sep 11, 2017 at 7:34 AM, Joseph Dunne <jdunne525@gmail.com> wrote:\n\n> When I merge ... however my commit-msg hook does not run.  (The\n> commit-msg hook works fine in all other commits / merges.)\n\nWhen using git-commit, but not git-merge?\n\nSee the discussion of patches at\nhttps://public-inbox.org/git/20170907220429.31312-1-sbeller@google.com/\n"},{"id":"327903","messageId":"CAC7pkbQwn8pvLLCtjsEkKo7PJozycdDbnq2XLWbmOm_KHEjU-w@mail.gmail.com","threadId":"46735","inReplyTo":"CAGZ79kZLvAgSgckQ7Doo_E7aY+L6xtv2Kq0xbO6GSZL5ZAb7TQ@mail.gmail.com","subject":"Re: commit-msg hook does not run on merge with --no-ff option","fromName":"Joseph Dunne","fromEmail":"jdunne525@gmail.com","sentAt":"2017-09-12T18:24:21Z","receivedAt":"2017-09-12T18:24:26Z","isPatch":false,"sender":{"key":"jdunne525@gmail.com","avatar":null},"body":"Sorry I don't understand your question.  The commit-msg hook runs\nproperly in all cases except when I perform a merge with the --no-ff\noption enabled.\n\nOn Mon, Sep 11, 2017 at 12:25 PM, Stefan Beller <sbeller@google.com> wrote:\n> On Mon, Sep 11, 2017 at 7:34 AM, Joseph Dunne <jdunne525@gmail.com> wrote:\n>\n>> When I merge ... however my commit-msg hook does not run.  (The\n>> commit-msg hook works fine in all other commits / merges.)\n>\n> When using git-commit, but not git-merge?\n>\n> See the discussion of patches at\n> https://public-inbox.org/git/20170907220429.31312-1-sbeller@google.com/\n"},{"id":"328090","messageId":"1505440235.1862.9.camel@gmail.com","threadId":"46735","inReplyTo":"CAC7pkbQwn8pvLLCtjsEkKo7PJozycdDbnq2XLWbmOm_KHEjU-w@mail.gmail.com","subject":"Re: commit-msg hook does not run on merge with --no-ff option","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-09-15T01:50:35Z","receivedAt":"2017-09-15T01:50:46Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Tue, 2017-09-12 at 13:24 -0500, Joseph Dunne wrote:\n> Sorry I don't understand your question.  The commit-msg hook runs\n> properly in all cases except when I perform a merge with the --no-ff\n> option enabled.\n> \n\nIt's working just as the documentation says it does (emphasis mine),\n\n\n    This hook is invoked by **git commit**, and can be bypassed with the --no-verify option.\n    It takes a single parameter, the name of the file that holds the proposed commit log\n    message. Exiting with a non-zero status causes the git commit to abort.\n\n\n    It says that 'commit-msg' hook is invoked only for a \"commit\" (it's not\n    a MERGE-msg hook you see, it doesn't exist anyway). In case you see the\n    hook getting invoked for a merge then that's an issue, I guess. For\n    what kind of merges do you see the 'commit-msg' hook getting invoked? \n\n        -- \n        Kaartic\n"},{"id":"328125","messageId":"CAC7pkbREUZxG0drWVpV43TFv7AVi2agJkRtXZgNsLErk3iBc-w@mail.gmail.com","threadId":"46735","inReplyTo":"1505440235.1862.9.camel@gmail.com","subject":"Re: commit-msg hook does not run on merge with --no-ff option","fromName":"Joseph Dunne","fromEmail":"jdunne525@gmail.com","sentAt":"2017-09-15T13:19:08Z","receivedAt":"2017-09-15T13:19:15Z","isPatch":false,"sender":{"key":"jdunne525@gmail.com","avatar":null},"body":"Valid point.  The way my project is set up I always get a conflict on\nmerge operations, so technically all my merges (except fast forward\nmerges) end with a git-commit, which of course runs the commit-msg\nhook.  It seems everything is working as designed.  Shame there isn't\na merge-msg hook.\n\nIt seems I have no choice but to work around this issue.  Thanks for your help.\n\nOn Thu, Sep 14, 2017 at 8:50 PM, Kaartic Sivaraam\n<kaarticsivaraam91196@gmail.com> wrote:\n> On Tue, 2017-09-12 at 13:24 -0500, Joseph Dunne wrote:\n>> Sorry I don't understand your question.  The commit-msg hook runs\n>> properly in all cases except when I perform a merge with the --no-ff\n>> option enabled.\n>>\n>\n> It's working just as the documentation says it does (emphasis mine),\n>\n>\n>     This hook is invoked by **git commit**, and can be bypassed with the --no-verify option.\n>     It takes a single parameter, the name of the file that holds the proposed commit log\n>     message. Exiting with a non-zero status causes the git commit to abort.\n>\n>\n>     It says that 'commit-msg' hook is invoked only for a \"commit\" (it's not\n>     a MERGE-msg hook you see, it doesn't exist anyway). In case you see the\n>     hook getting invoked for a merge then that's an issue, I guess. For\n>     what kind of merges do you see the 'commit-msg' hook getting invoked?\n>\n>         --\n>         Kaartic\n"},{"id":"328168","messageId":"xmqq7ewzwuo6.fsf@gitster.mtv.corp.google.com","threadId":"46735","inReplyTo":"CAC7pkbREUZxG0drWVpV43TFv7AVi2agJkRtXZgNsLErk3iBc-w@mail.gmail.com","subject":"Re: commit-msg hook does not run on merge with --no-ff option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-15T20:53:13Z","receivedAt":"2017-09-15T20:53:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joseph Dunne <jdunne525@gmail.com> writes:\n\n> Valid point.  The way my project is set up I always get a conflict on\n> merge operations, so technically all my merges (except fast forward\n> merges) end with a git-commit, which of course runs the commit-msg\n> hook.  It seems everything is working as designed.  Shame there isn't\n> a merge-msg hook.\n>\n> It seems I have no choice but to work around this issue.  Thanks for your help.\n\nI think Stefan wanted to say in his message upthread that with an\nupdate still in flight you may not need a workaround.\n"},{"id":"328496","messageId":"CAC7pkbTU9Ts01p8kDJXqzk2yy=8Y-8dmkGhAkJ96m4D5zCzdRQ@mail.gmail.com","threadId":"46735","inReplyTo":"xmqq7ewzwuo6.fsf@gitster.mtv.corp.google.com","subject":"Re: commit-msg hook does not run on merge with --no-ff option","fromName":"Joseph Dunne","fromEmail":"jdunne525@gmail.com","sentAt":"2017-09-20T20:09:04Z","receivedAt":"2017-09-20T20:09:12Z","isPatch":false,"sender":{"key":"jdunne525@gmail.com","avatar":null},"body":"For anyone who stumbles upon this in the future, I found a very simple\nworkaround to force the commit hooks (including commit-msg) to run\nfollowing a merge operation:  Simply create a post-merge hook which\ntriggers an amended commit with no changes.\n\npost-merge hook:\n\n#!/bin/bash\ngit commit --amend -C HEAD\n\nOn Fri, Sep 15, 2017 at 3:53 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Joseph Dunne <jdunne525@gmail.com> writes:\n>\n>> Valid point.  The way my project is set up I always get a conflict on\n>> merge operations, so technically all my merges (except fast forward\n>> merges) end with a git-commit, which of course runs the commit-msg\n>> hook.  It seems everything is working as designed.  Shame there isn't\n>> a merge-msg hook.\n>>\n>> It seems I have no choice but to work around this issue.  Thanks for your help.\n>\n> I think Stefan wanted to say in his message upthread that with an\n> update still in flight you may not need a workaround.\n"}]}