git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* commit-msg hook does not run on merge with --no-ff option
@ 2017-09-11 14:34 Joseph Dunne
  2017-09-11 17:25 ` Stefan Beller
  0 siblings, 1 reply; 7+ messages in thread
From: Joseph Dunne @ 2017-09-11 14:34 UTC (permalink / raw)
  To: git

I’ve globally configured git master branch to use the –no-ff option in
my .gitconfig file:
[branch "master"]
                mergeoptions = “-–no-ff”

When I merge a branch into master that would normally be a fast
forward merge, the merge happens fine and follows the option –no-ff,
creating a new commit, however my commit-msg hook does not run.  (The
commit-msg hook works fine in all other commits / merges.)

I tried changing my commit-msg hook to just be “exit 1” and it doesn’t
abort a no-ff merge, so I’m certain the hook is just not being
executed.

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

* Re: commit-msg hook does not run on merge with --no-ff option
  2017-09-11 14:34 commit-msg hook does not run on merge with --no-ff option Joseph Dunne
@ 2017-09-11 17:25 ` Stefan Beller
  2017-09-12 18:24   ` Joseph Dunne
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Beller @ 2017-09-11 17:25 UTC (permalink / raw)
  To: Joseph Dunne; +Cc: git@vger.kernel.org

On Mon, Sep 11, 2017 at 7:34 AM, Joseph Dunne <jdunne525@gmail.com> wrote:

> When I merge ... however my commit-msg hook does not run.  (The
> commit-msg hook works fine in all other commits / merges.)

When using git-commit, but not git-merge?

See the discussion of patches at
https://public-inbox.org/git/20170907220429.31312-1-sbeller@google.com/

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

* Re: commit-msg hook does not run on merge with --no-ff option
  2017-09-11 17:25 ` Stefan Beller
@ 2017-09-12 18:24   ` Joseph Dunne
  2017-09-15  1:50     ` Kaartic Sivaraam
  0 siblings, 1 reply; 7+ messages in thread
From: Joseph Dunne @ 2017-09-12 18:24 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git@vger.kernel.org

Sorry I don't understand your question.  The commit-msg hook runs
properly in all cases except when I perform a merge with the --no-ff
option enabled.

On Mon, Sep 11, 2017 at 12:25 PM, Stefan Beller <sbeller@google.com> wrote:
> On Mon, Sep 11, 2017 at 7:34 AM, Joseph Dunne <jdunne525@gmail.com> wrote:
>
>> When I merge ... however my commit-msg hook does not run.  (The
>> commit-msg hook works fine in all other commits / merges.)
>
> When using git-commit, but not git-merge?
>
> See the discussion of patches at
> https://public-inbox.org/git/20170907220429.31312-1-sbeller@google.com/

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

* Re: commit-msg hook does not run on merge with --no-ff option
  2017-09-12 18:24   ` Joseph Dunne
@ 2017-09-15  1:50     ` Kaartic Sivaraam
  2017-09-15 13:19       ` Joseph Dunne
  0 siblings, 1 reply; 7+ messages in thread
From: Kaartic Sivaraam @ 2017-09-15  1:50 UTC (permalink / raw)
  To: Joseph Dunne, Stefan Beller; +Cc: git@vger.kernel.org

On Tue, 2017-09-12 at 13:24 -0500, Joseph Dunne wrote:
> Sorry I don't understand your question.  The commit-msg hook runs
> properly in all cases except when I perform a merge with the --no-ff
> option enabled.
> 

It's working just as the documentation says it does (emphasis mine),


    This hook is invoked by **git commit**, and can be bypassed with the --no-verify option.
    It takes a single parameter, the name of the file that holds the proposed commit log
    message. Exiting with a non-zero status causes the git commit to abort.


    It says that 'commit-msg' hook is invoked only for a "commit" (it's not
    a MERGE-msg hook you see, it doesn't exist anyway). In case you see the
    hook getting invoked for a merge then that's an issue, I guess. For
    what kind of merges do you see the 'commit-msg' hook getting invoked? 

        -- 
        Kaartic

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

* Re: commit-msg hook does not run on merge with --no-ff option
  2017-09-15  1:50     ` Kaartic Sivaraam
@ 2017-09-15 13:19       ` Joseph Dunne
  2017-09-15 20:53         ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Joseph Dunne @ 2017-09-15 13:19 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: Stefan Beller, git@vger.kernel.org

Valid point.  The way my project is set up I always get a conflict on
merge operations, so technically all my merges (except fast forward
merges) end with a git-commit, which of course runs the commit-msg
hook.  It seems everything is working as designed.  Shame there isn't
a merge-msg hook.

It seems I have no choice but to work around this issue.  Thanks for your help.

On Thu, Sep 14, 2017 at 8:50 PM, Kaartic Sivaraam
<kaarticsivaraam91196@gmail.com> wrote:
> On Tue, 2017-09-12 at 13:24 -0500, Joseph Dunne wrote:
>> Sorry I don't understand your question.  The commit-msg hook runs
>> properly in all cases except when I perform a merge with the --no-ff
>> option enabled.
>>
>
> It's working just as the documentation says it does (emphasis mine),
>
>
>     This hook is invoked by **git commit**, and can be bypassed with the --no-verify option.
>     It takes a single parameter, the name of the file that holds the proposed commit log
>     message. Exiting with a non-zero status causes the git commit to abort.
>
>
>     It says that 'commit-msg' hook is invoked only for a "commit" (it's not
>     a MERGE-msg hook you see, it doesn't exist anyway). In case you see the
>     hook getting invoked for a merge then that's an issue, I guess. For
>     what kind of merges do you see the 'commit-msg' hook getting invoked?
>
>         --
>         Kaartic

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

* Re: commit-msg hook does not run on merge with --no-ff option
  2017-09-15 13:19       ` Joseph Dunne
@ 2017-09-15 20:53         ` Junio C Hamano
  2017-09-20 20:09           ` Joseph Dunne
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2017-09-15 20:53 UTC (permalink / raw)
  To: Joseph Dunne; +Cc: Kaartic Sivaraam, Stefan Beller, git@vger.kernel.org

Joseph Dunne <jdunne525@gmail.com> writes:

> Valid point.  The way my project is set up I always get a conflict on
> merge operations, so technically all my merges (except fast forward
> merges) end with a git-commit, which of course runs the commit-msg
> hook.  It seems everything is working as designed.  Shame there isn't
> a merge-msg hook.
>
> It seems I have no choice but to work around this issue.  Thanks for your help.

I think Stefan wanted to say in his message upthread that with an
update still in flight you may not need a workaround.

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

* Re: commit-msg hook does not run on merge with --no-ff option
  2017-09-15 20:53         ` Junio C Hamano
@ 2017-09-20 20:09           ` Joseph Dunne
  0 siblings, 0 replies; 7+ messages in thread
From: Joseph Dunne @ 2017-09-20 20:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Kaartic Sivaraam, Stefan Beller, git@vger.kernel.org

For anyone who stumbles upon this in the future, I found a very simple
workaround to force the commit hooks (including commit-msg) to run
following a merge operation:  Simply create a post-merge hook which
triggers an amended commit with no changes.

post-merge hook:

#!/bin/bash
git commit --amend -C HEAD

On Fri, Sep 15, 2017 at 3:53 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Joseph Dunne <jdunne525@gmail.com> writes:
>
>> Valid point.  The way my project is set up I always get a conflict on
>> merge operations, so technically all my merges (except fast forward
>> merges) end with a git-commit, which of course runs the commit-msg
>> hook.  It seems everything is working as designed.  Shame there isn't
>> a merge-msg hook.
>>
>> It seems I have no choice but to work around this issue.  Thanks for your help.
>
> I think Stefan wanted to say in his message upthread that with an
> update still in flight you may not need a workaround.

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

end of thread, other threads:[~2017-09-20 20:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-11 14:34 commit-msg hook does not run on merge with --no-ff option Joseph Dunne
2017-09-11 17:25 ` Stefan Beller
2017-09-12 18:24   ` Joseph Dunne
2017-09-15  1:50     ` Kaartic Sivaraam
2017-09-15 13:19       ` Joseph Dunne
2017-09-15 20:53         ` Junio C Hamano
2017-09-20 20:09           ` Joseph Dunne

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).