Re: post-checkout hook aborts rebase
- From
Chris Torek <chris.torek@gmail.com>
- Date
- Aug 27, 2020, 05:44 UTC
- Message-ID
- <CAPx1GvfSt=s5VP9_+ZtndHWaBZ5W7nFxAf8bTF2tXnJkS95Dfg@mail.gmail.com>
- In-Reply-To
- <CAHr-Uu8umDQJ=LORaBNJX+wnmaeM1hHxxpG7xROPgCqgEPrwdw@mail.gmail.com>
On Wed, Aug 26, 2020 at 5:48 PM Tom Rutherford <tmrutherford@gmail.com> wrote:
Show 8 quoted lines
> > Thank you for the response Junio. > > For what it's worth, my hook does not make changes to the repo. It's > running a command to check that the installed version of our > dependencies match the version specified in the commit being checked > out, and merely warns if the two don't match (then exits with a > nonzero return code).
I've run into this before myself. The core of the bug is that when `git checkout` runs the post-checkout hook, whatever exit status that hook has, `git checkout` has the same exit status.
This might be intended as a feature, but if so, the documentation needs a tweak: the githooks docs say in part
This hook cannot affect the outcome of git checkout.
If "outcome" includes exit status -- to me, it does -- either the docs are wrong or the code is wrong.
> For this reason it's been convenient that the hook runs during > rebases, but I find it surprising that the nonzero return code would > impact the rebase.
I have to agree with this, too.
(The simplest fix would be to have `git checkout` ignore the status from the post-checkout hook, of course, and just exit 0 for success.)
Chris