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.