Re: [PATCH v2 1/4] git-merge: Honor pre-merge hook
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Jul 29, 2019, 20:00 UTC
- Message-ID
- <CAN0heSpi3rYAR5XmT4FM_YB746JjYHxmQHwASk4778saBKoUUA@mail.gmail.com>
- In-Reply-To
- <e8b3fd8a5bf8f77795454a901fecaa585701eeb2.1563490164.git.steadmon@google.com>
On Fri, 19 Jul 2019 at 00:57, Josh Steadmon <steadmon@google.com> wrote:
Show 16 quoted lines
> --- /dev/null > +++ b/templates/hooks--pre-merge.sample > @@ -0,0 +1,13 @@ > +#!/bin/sh > +# > +# An example hook script to verify what is about to be committed. > +# Called by "git merge" with no arguments. The hook should > +# exit with non-zero status after issuing an appropriate message to > +# stderr if it wants to stop the merge commit. > +# > +# To enable this hook, rename this file to "pre-merge". > + > +. git-sh-setup > +test -x "$GIT_DIR/hooks/pre-commit" && > + exec "$GIT_DIR/hooks/pre-commit" > +:
I'm pretty certain that my comment here was with respect to the ":", which made me think "hmmm, won't : always exit successfully?". My slightly less ignorant self of today answers "sure, but we won't always get that far" -- the "exec" is pretty important, and it will cause the current shell to be replaced with the hook invocation. So however the pre-commit hook decides to exit, that'll be our exit status.
I retract my comment from back then.
Martin