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

Re: [PATCH 4/5] rebase -i: don't fork git checkout

From
Elijah Newren <newren@gmail.com>
Date
Sep 9, 2021, 15:03 UTC
Message-ID
<CABPp-BG=pWhLpjKKSbgUyuaSEwjdkhwv8Vb1Ut1-n3LziSy_pQ@mail.gmail.com>
In-Reply-To
<39ad40c9297531a2d42b7263a1d41b1ecbc23c0a.1631108472.git.gitgitgadget@gmail.com>

On Wed, Sep 8, 2021 at 6:44 AM Phillip Wood via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 10 quoted lines
>
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> The "apply" based rebase has avoided forking git checkout since
> ac7f467fef ("builtin/rebase: support running "git rebase <upstream>"",
> 2018-08-07). The code that handles the checkout was moved into libgit
> by b309a97108 ("reset: extract reset_head() from rebase", 2020-04-07)
> so lets start using it for the "merge" based rebase as well. This
> opens the way for us to stop calling the post-checkout hook in the
> future.
Wahoo!  So exciting to see this, and for the future plans mentioned here.  :-)
Show 58 quoted lines
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>  sequencer.c | 29 ++++-------------------------
>  1 file changed, 4 insertions(+), 25 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index d51440ddcd9..1a9dbc70d3c 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -4192,42 +4192,21 @@ int apply_autostash_oid(const char *stash_oid)
>         return apply_save_autostash_oid(stash_oid, 1);
>  }
>
> -static int run_git_checkout(struct repository *r, struct replay_opts *opts,
> -                           const char *commit, const char *action)
> -{
> -       struct child_process cmd = CHILD_PROCESS_INIT;
> -       int ret;
> -
> -       cmd.git_cmd = 1;
> -
> -       strvec_push(&cmd.args, "checkout");
> -       strvec_push(&cmd.args, commit);
> -       strvec_pushf(&cmd.env_array, GIT_REFLOG_ACTION "=%s", action);
> -
> -       if (opts->verbose)
> -               ret = run_command(&cmd);
> -       else
> -               ret = run_command_silent_on_success(&cmd);
> -
> -       if (!ret)
> -               discard_index(r->index);
> -
> -       return ret;
> -}
> -
>  static int checkout_onto(struct repository *r, struct replay_opts *opts,
>                          const char *onto_name, const struct object_id *onto,
>                          const struct object_id *orig_head)
>  {
>         const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
>
> -       if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
> +       if (reset_head(r, onto, "checkout", NULL, RESET_HEAD_DETACH |
> +                      RESET_ORIG_HEAD | RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
> +                      NULL, action, "rebase")) {
>                 apply_autostash(rebase_path_autostash());
>                 sequencer_remove_state(opts);
>                 return error(_("could not detach HEAD"));
>         }
>
> -       return update_ref(NULL, "ORIG_HEAD", orig_head, NULL, 0, UPDATE_REFS_MSG_ON_ERR);
> +       return 0;
>  }
>
>  static int stopped_at_head(struct repository *r)
> --
> gitgitgadget
Previous: Philippe BlainNext: Phillip Wood via GitGitGadget
Message 22 of 31 in “rebase -i: a couple of small improvements”
  1. 0/5 rebase -i: a couple of small improvementsPhillip Wood via GitGitGadget, Sep 8, 2021
  2. 1/5 sequencer.c: factor out a functionPhillip Wood via GitGitGadget, Sep 8, 2021
  3. Eric SunshineSep 8, 2021
  4. Phillip WoodSep 9, 2021
  5. Johannes SchindelinSep 9, 2021
  6. 2/5 rebase: fix todo-list rereadingPhillip Wood via GitGitGadget, Sep 8, 2021
  7. Johannes SchindelinSep 9, 2021
  8. 3/5 reset_head(): mark oid parameter as constPhillip Wood via GitGitGadget, Sep 8, 2021
  9. 4/5 rebase -i: don't fork git checkoutPhillip Wood via GitGitGadget, Sep 8, 2021
  10. Philippe BlainSep 8, 2021
  11. Phillip WoodSep 9, 2021
  12. Philippe BlainSep 9, 2021
  13. Phillip WoodSep 9, 2021
  14. Elijah NewrenSep 9, 2021
  15. Philippe BlainSep 10, 2021
  16. Phillip WoodSep 15, 2021
  17. Johannes SchindelinSep 9, 2021
  18. Philippe BlainSep 9, 2021
  19. Johannes SchindelinSep 9, 2021
  20. Johannes SchindelinSep 10, 2021
  21. Philippe BlainSep 10, 2021
  22. Elijah NewrenSep 9, 2021
  23. 5/5 rebase: remove unused parameterPhillip Wood via GitGitGadget, Sep 8, 2021
  24. Johannes SchindelinSep 9, 2021
  25. Phillip WoodSep 9, 2021
  26. 0/2 rebase -i: a couple of small improvementsPhillip Wood via GitGitGadget, Sep 23, 2021
  27. 2/2 rebase: fix todo-list rereadingPhillip Wood via GitGitGadget, Sep 23, 2021
  28. Junio C HamanoSep 24, 2021
  29. Phillip WoodSep 28, 2021
  30. 1/2 sequencer.c: factor out a functionPhillip Wood via GitGitGadget, Sep 23, 2021
  31. Junio C HamanoSep 24, 2021

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.