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

Re: What about allowing multiple hooks?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 4, 2009, 10:01 UTC
Message-ID
<7vd4f3z8xu.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090103233252.GA12095@myhost>
Alexander Potashev <aspotashev@gmail.com> writes:
>> Thoughts?

I deliberately omitted support for multiple scripts in core git Porcelains to avoid this exact issue. It is a huge can of worms and it is dubious if you can have a coherent and generic enough semantics.

In the meantime, you can have a single .git/hooks/pre-commit script that defines your own convention. Maybe it uses .git/hooks/pre-commit.d/ directory, full of scripts, and implements the semantics you want, including:

 (1) the execution order and the naming convention of the scripts (e.g.
     they all live in pre-commit.d/ directory, and executed in ASCII byte
     value order of their names);
 (2) how their exit status combine together.  For example, maybe a failure
     from one of the scripts prevents none of the later scripts to even
     run and make the whole hook return a failure; maybe a failure will be
     remembered, but the other scripts may still want to be run to learn
     about the fact that the commit was attempted, and the whole hook
     returns a failure if any of them fail.
     In a hook that is run primarily for its side effects and not for
     validation, it may even be desireble if the whole hook returns a
     failure only when all of them fail, iow, for such a hook the status
     is not ANDed but ORed together.

Once you have such a framework and get help from others to widely try it in the field, it may prove generic enough to include it as the sample hook script to be installed everywhere.

Previous: Alexander PotashevNext: Anders Waldenborg
Message 5 of 10 in “What about allowing multiple hooks?”
  1. Marc WeberNov 21, 2008
  2. martin f krafftNov 21, 2008
  3. Rogan DawesNov 21, 2008
  4. Alexander PotashevJan 3, 2009
  5. Junio C HamanoJan 4, 2009
  6. Anders WaldenborgJan 21, 2009
  7. Johannes SchindelinJan 21, 2009
  8. Anders WaldenborgJan 21, 2009
  9. Johannes SchindelinJan 21, 2009
  10. Anders WaldenborgJan 22, 2009

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.