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

Re: [PATCH] merge: Run commit-msg hook

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 26, 2016, 21:05 UTC
Message-ID
<xmqq8twoyusq.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAGHpTBLr9q8h-+hVUzsTS1aS1TyZjz9gYM_T_ZBdY=o26JGaHw@mail.gmail.com>
Orgad Shaneh <orgads@gmail.com> writes:
Show 5 quoted lines
>> Hmm. This is not very convincing to me, as
>>
>> - if you call commit-msg in `git merge` now, why not `prepare-commit-msg`?
>
> prepare-commit-msg is already called, a few lines above this addition.

I do not see such call in contrib/example/git-merge.sh; could it be a recent bug that it calls it?

Show 7 quoted lines
>> - a merge is a different beast from a simple commit. That is why we have
>>   two different commands for them. A hook to edit the merge message may
>>   need to know the *second* parent commit, too, for example to generate
>>   a diffstat, or to add information about changes in an "evil commit".
>
> That is correct for a post-merge hook. Why should *message validation* differ
> between simple and merge commit?

Have you seen a typical merge commit message? They certainly look different to me and different rules would apply.

Show 6 quoted lines
>> - if Gerrit is the intended user, would it not make more sense to
>>   introduce a new hook, e.g. `merge-msg` (and `prepare-merge-msg`), as you
>>   have to teach Gerrit a new trick anyway?
>
> Why is that new? Every commit in gerrit has a Change-Id footer, which is
> generated by commit-msg hook.
Hmm, I didn't know Gerrit gave Change-ID to merges.

In any case, I would think this is completely new. Without this change, commit-msg was not called for merges, so Gerrit wouldn't have added Change-ID to merges with that mechanism.

A new merge-msg hook would make more sense, if we were making any change. I do not want to get yelled at by those who wrote their commit-msg hooks long time ago and have happily been using them that updated Git started calling them for their merges where their validation logic for their single-parent commit do not apply at all.

Previous: Junio C HamanoNext: Johannes Schindelin
Message 6 of 7 in “merge: Run commit-msg hook”
  1. merge: Run commit-msg hookOrgad Shaneh, Jul 26, 2016
  2. Johannes SchindelinJul 26, 2016
  3. Orgad ShanehJul 26, 2016
  4. Johannes SchindelinJul 26, 2016
  5. Junio C HamanoJul 26, 2016
  6. Junio C HamanoJul 26, 2016
  7. Johannes SchindelinJul 27, 2016

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.