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

Re: [PATCH] git-merge: run commit hooks when making merge commits

From
Sam Vilain <sam@vilain.net>
Date
Jul 11, 2007, 23:21 UTC
Message-ID
<469565FF.5040103@vilain.net>
In-Reply-To
<7vd4yy4opa.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 23 quoted lines
> Sam Vilain <sam.vilain@catalyst.net.nz> writes:
> 
>> git-merge.sh was not running the commit hooks, so run them in the two
>> places where we go to commit.
>>
>> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
>> ---
>>    Not sure if it should call these or some specialist hooks, like
>>    git-am does.
> 
> I suspect some people have pre-commit scripts that have been
> meant to catch style errors for their own commits, and invoking
> that on merge would wreak havoc --- there is not much you can do
> if you want to get the work done by somebody else at that point.
> Introducing a new pre-merge-commit hook would probably be safer;
> if one wants to use the same check as one's pre-commit does, the
> new hook in the repository can exec $GIT_DIR/hooks/pre-commit.
> 
> The commit-msg hook I have no clue what people usually use it
> for in the real world, but a merge commit message tends to be
> quite different from the message you would give to your own
> straight line commits, so custom reformatting rules people have
> in commit-msg hook may not apply to merge commit messages.

True. OTOH, if you commit with `git commit` after a merge which failed or was called with --no-commit, then it will call the commit hook. So those scripts would have to deal with that case anyway.

So, should `git commit` detect it is committing a merge and call the merge-hooks, should we use the same hooks, or, should this be something like hooks/*-automerge ?

Sam.
Previous: Junio C HamanoNext: Andy Parkins
Message 3 of 4 in “git-merge: run commit hooks when making merge commits”
  1. git-merge: run commit hooks when making merge commitsSam Vilain, Jul 11, 2007
  2. Junio C HamanoJul 11, 2007
  3. Sam VilainJul 11, 2007
  4. Andy ParkinsJul 12, 2007

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.