Subject: [PATCH 2/4] builtin/worktree.c: Update checkout_worktree() to use git-worktree

From: Jacob Abel <[email-masked]>
Date: Fri, 04 Nov 2022 01:03:14 +0000

Updates the function to call `git checkout` instead of
`git reset --hard` to simplify adding orphan support.

Signed-off-by: Jacob Abel <[email-masked]>
---
 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index b3373fbbd6..d40f771848 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -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);
--
2.37.4