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

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
Previous: Tom RutherfordNext: Junio C Hamano
Message 5 of 16 in “post-checkout hook aborts rebase”
  1. Tom RutherfordAug 26, 2020
  2. Junio C HamanoAug 27, 2020
  3. Junio C HamanoAug 27, 2020
  4. Tom RutherfordAug 27, 2020
  5. Chris TorekAug 27, 2020
  6. Junio C HamanoAug 27, 2020
  7. Chris TorekAug 27, 2020
  8. Elijah NewrenAug 27, 2020
  9. Chris TorekAug 27, 2020
  10. Phillip WoodSep 9, 2020
  11. Tom RutherfordSep 9, 2020
  12. Philippe BlainSep 11, 2020
  13. Junio C HamanoSep 12, 2020
  14. Elijah NewrenAug 27, 2020
  15. Junio C HamanoAug 27, 2020
  16. Elijah NewrenAug 27, 2020

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.