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

Re: [PATCH 0/3] pre-merge-hook

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 6, 2012, 08:16 UTC
Message-ID
<50485BCB.20607@drmicha.warpmail.net>
In-Reply-To
<7v8vcn68o9.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 06.09.2012 07:07:
Show 25 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> The pre-commit hook is often used to ensure certain properties of each
>> comitted tree like formatting or coding standards, validity (lint/make)
>> or code quality (make test). But merges introduce new commits unless
>> they are fast forwards, and therefore they can break these properties
>> because the pre-commit hook is not run by "git merge".
>>
>> Introduce a pre-merge hook which works for (non ff, automatic) merges
>> like pre-commit does for commits. Typically this will just call the
>> pre-commit hook (like in the sample hook), but it does not need to.
> 
> When your merge asks for a help from you to resolve conflict, you
> conclude with "git commit", and at that point, pre-commit hook will
> have a chance to reject it, presumably.  That means for any project
> that wants to audit a merge via hook, their pre-commit hook MUST be
> prepared to look at and judge a merge.  Given that, is a separate
> hook that "can just call the pre-commit but does not need to" really
> needed and useful?
> 
> I admit that I haven't thought things through, but adding a boolean
> "merge.usePreCommitHook" smells like a more appropriate approach to
> me.
> 
> I dunno.
That would be an option ;)

Seriously, that would make the case where both hooks are the same even simpler, obviously. On the other hand it would make the other case more difficult. But, really, since non-automatic merges call pre-commit now, and that is probably to stay, catching those with a different (part of the pre-commit) hook will stay difficult anyways. So the question is really more whether we prefer to bloat the config space or the name space by this.

Either works for me, and if we don't change the current behaviour (pre-commit-hook resp. no hook for non-automatic merges resp. automatic merges) the config option is probably less confusing.

Michael
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 16 in “pre-merge-hook”
  1. 0/3 pre-merge-hookMichael J Gruber, Sep 5, 2012
  2. 1/3 git-merge: Honor pre-merge hookMichael J Gruber, Sep 5, 2012
  3. Michael HaggertySep 5, 2012
  4. Michael J GruberSep 6, 2012
  5. Michael HaggertySep 6, 2012
  6. 0/4 pre-commit hook for mergesMichael J Gruber, Sep 6, 2012
  7. 1/4 merge: document prepare-commit-msg hook usageMichael J Gruber, Sep 6, 2012
  8. 2/4 git-merge: Honor pre-commit hook based on configMichael J Gruber, Sep 6, 2012
  9. 3/4 merge: --no-verify to bypass pre-commit hookMichael J Gruber, Sep 6, 2012
  10. 4/4 t7503: add tests for pre-commit hook (merge)Michael J Gruber, Sep 6, 2012
  11. 2/3 merge: --no-verify to bypass pre-merge hookMichael J Gruber, Sep 5, 2012
  12. 3/3 t7503: add tests for pre-merge-hookMichael J Gruber, Sep 5, 2012
  13. Junio C HamanoSep 6, 2012
  14. Michael J GruberSep 6, 2012
  15. Junio C HamanoSep 6, 2012
  16. Michael J GruberSep 7, 2012

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.