# Re: [RFC/PATCH] merge: honor prepare-commit-msg hook

2 messages from 2011-03-09 to 2011-03-09. Participants: Jeffrey Middleton, Jay Soffian.
Thread: https://gitlist.dev/t/26697

## Jeffrey Middleton, 2011-03-09 00:16

Subject: Re: [RFC/PATCH] merge: honor prepare-commit-msg hook
Message-ID: <AANLkTimqxNNJ7ezBYC8V_pW5=HB1md1xVrnKFV8sVBue@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimqxNNJ7ezBYC8V_pW5%3DHB1md1xVrnKFV8sVBue%40mail.gmail.com

```
I'd like to add a voice to the support for calling the
prepare-commit-msg and post-commit hooks during a merge.

Reading the documentation, it seems like surely prepare-commit-msg
would be called: the description of the hook mentions that the second
argument might be "merge". The sample hook (also mentioned there)
targets only merge commits, but happens to work because it's designed
to only have an effect if there is a "Conflicts:" section, which
therefore means the user is committing manually. Another possible
merge-related use case for the hook would be intelligently rewriting
the subject, e.g. to canonicalize remote names in integration-style
merges.  If y'all don't agree, I'd suggest modifying the documentation
to clarify that the hook is only called for manually-committed merges.

My instinct is that post-commit makes sense too - if you want to print
some extra information after a commit is recorded, why should it just
be non-merges?

(and just in case, this is a reply to an old thread, including a
proposed patch:
http://thread.gmane.org/gmane.comp.version-control.git/151297/ )

Jeffrey

Junio C Hamano <gitster <at> pobox.com> writes:
> Jay Soffian <jaysoffian <at> gmail.com> writes:
> > ---
> > I couldn't figure out why my prepare-commit-msg wasn't being honored
> > by git merge.
>
> It has been that way from day one, it appears.
>
> The bypassing of pre-commit hook was and remains to be a conscious design
> decision.  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.
>
> On the other hand, I think letting people use prepare-commit-msg for
> merges might  make sense.  Indeed, "git commit" is prepared to call
> prepare-commit-msg telling the hook that it is concluding a merge, when
> your "git merge" stopped due to a conflict (or you stopped it from making
> a new commit with --no-commit).
>
> I don't know about the other hooks "git commit" normally calls.  Both
> "commit-msg" and "post-commit" may make sense, but I don't care too deeply
> either way---I don't care too deeply for pre-commit either ;-).

```

## Jay Soffian, 2011-03-09 22:50

Subject: Re: [RFC/PATCH] merge: honor prepare-commit-msg hook
Message-ID: <AANLkTi=yxrLGEPQVG=knkZgXyeiAX+f_cF+mfJ3BYf+O@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DyxrLGEPQVG%3DknkZgXyeiAX%2Bf_cF%2BmfJ3BYf%2BO%40mail.gmail.com
In-Reply-To: <AANLkTimqxNNJ7ezBYC8V_pW5=HB1md1xVrnKFV8sVBue@mail.gmail.com>

```
On Tue, Mar 8, 2011 at 7:16 PM, Jeffrey Middleton <jefromi@gmail.com> wrote:
> I'd like to add a voice to the support for calling the
> prepare-commit-msg and post-commit hooks during a merge.

See 65969d4 (merge: honor prepare-commit-msg hook, 2011-02-14), now in
master. I didn't do anything about the other hooks though.

j.

```
