git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
JMJeffrey Middleton <jefromi@gmail.com>
Date
Mar 9, 2011, 00:16 UTC
Message-ID
<AANLkTimqxNNJ7ezBYC8V_pW5=HB1md1xVrnKFV8sVBue@mail.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:
Show 22 quoted lines
> 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 ;-).
Next: Jay Soffian
Message 1 of 2 in “Re: [RFC/PATCH] merge: honor prepare-commit-msg hook”
  1. Jeffrey MiddletonMar 9, 2011
  2. Jay SoffianMar 9, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.