Skip to content

Commit 1c56190

Browse files
sunshinecogitster
authored andcommitted
worktree: populate via "git reset --hard" rather than "git checkout"
Now that git-worktree handles all functionality (--force, --detach, -b/-B) previously delegated to git-checkout, actual population of the new worktree can be accomplished more directly and lightweight with "git reset --hard" in place of "git checkout". Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed197a6 commit 1c56190

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

builtin/worktree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ static int add_worktree(const char *path, const char *refname,
266266

267267
fprintf_ln(stderr, _("Preparing %s (identifier %s)"), path, name);
268268

269-
setenv("GIT_CHECKOUT_NEW_WORKTREE", "1", 1);
270269
argv_array_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
271270
argv_array_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
272271
memset(&cp, 0, sizeof(cp));
@@ -285,7 +284,7 @@ static int add_worktree(const char *path, const char *refname,
285284

286285
cp.argv = NULL;
287286
argv_array_clear(&cp.args);
288-
argv_array_push(&cp.args, "checkout");
287+
argv_array_pushl(&cp.args, "reset", "--hard", NULL);
289288
cp.env = child_env.argv;
290289
ret = run_command(&cp);
291290
if (!ret) {

0 commit comments

Comments
 (0)