Re: [PATCH 2/4] builtin/worktree.c: Update checkout_worktree() to use git-worktree
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Nov 4, 2022, 20:45 UTC
- Message-ID
- <Y2V55Mx4aC1r/0gj@nand.local>
- In-Reply-To
- <221104.86sfizzeq7.gmgdl@evledraar.gmail.com>
On Fri, Nov 04, 2022 at 02:32:11AM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 12 quoted lines
> > @@ -357,7 +357,7 @@ static int checkout_worktree(const struct add_opts *opts,
> > {
> > struct child_process cp = CHILD_PROCESS_INIT;
> > cp.git_cmd = 1;
> > - strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
> > + strvec_pushl(&cp.args, "checkout", "--no-recurse-submodules", NULL);
> > if (opts->quiet)
> > strvec_push(&cp.args, "--quiet");
> > strvec_pushv(&cp.env, child_env->v);
>
> Won't we now start to run the post-checkout when doing this, and is that
> intended?Beyond that, does the change between `reset --hard` and `checkout`'s treatment of modified files in the working copy matter?
I don't know enough about the worktree code off-hand to know if this function will ever run in an already-populated worktree that may be carrying its own modifications.
Thanks, Taylor