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

Re: post-checkout hook aborts rebase

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 27, 2020, 17:27 UTC
Message-ID
<xmqqd03cq9r5.fsf@gitster.c.googlers.com>
In-Reply-To
<CABPp-BF=ydfHE2XqN4L9qfeAg3AZL9yNJhs4rykGj0baT1Eh6g@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 27 quoted lines
> On Wed, Aug 26, 2020 at 5:24 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>> > ...  If "git rebase" or whatever
>> > command wanted to place files and the index into some state by using
>> > "git checkout" command, and if the post-checkout hook mucked with
>> > the state in such a way that contradicts with what the "git rebase"
>> > command wanted them to be in, it is not surprising the hook's behavior
>> > broke "git rebase"'s operation.
>>
>> Having said all that, I actually think that "rebase" shouldn't be
>> invoking "git checkout" (and its equivalent) internally when
>> switching to a specific version, in such a way that it would trigger
>> any end-user specified hooks and allow them to muck with the working
>> tree and the index state.
>>
>> I haven't checked the actual implementation of "git rebase" for
>> quite some time to be sure, but we have lower-level plumbing
>> commands that are not affected by the end-user hooks for exactly
>> that kind of "build higher-level commands by synthesis of
>> lower-level machinery", and it is very possible that what we are
>> looking at is actually a bug that needs to be fixed.  I dunno.
>>
>> Thanks.
>
> Yes, and I think we should also make rebase stop invoking "git commit" too.

Note that I didn't say we should make it stop invoking "git checkout".

We could invent a mechanism that disables all the hook invocations and other customizations [*1*] (done e.g. via the configuration variables) for internal use of the Porcelain commands, and use it when "rebase" invokes Porcelains like "checkout", "commit" as its implementation detail, for example (some "invocations" I think bypass the run_command() inteface and instead done by directly calling the implementation detail of "checkout" and "commit", but the principles are the same).

[Footnote]
*1* of course, it becomes a balancing act to decide what kind of
    customizations are OK to honor under such a mode.
Previous: Elijah NewrenNext: Elijah Newren
Message 15 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.