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 <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Jul 17, 2015 at 19:00 UTC
1c56190aec502d946eb3db7365d6e54e2ffc7bd2
1 file changed
+1
-2
builtin/worktree.c
+1
-2
@@ -266,7 +266,6 @@ static int add_worktree(const char *path, const char *refname,
266
267
fprintf_ln(stderr, _("Preparing %s (identifier %s)"), path, name);
268
269
- setenv("GIT_CHECKOUT_NEW_WORKTREE", "1", 1);
269
argv_array_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
270
argv_array_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
271
memset(&cp, 0, sizeof(cp));
@@ -285,7 +284,7 @@ static int add_worktree(const char *path, const char *refname,
284
285
cp.argv = NULL;
286
argv_array_clear(&cp.args);
288
- argv_array_push(&cp.args, "checkout");
287
+ argv_array_pushl(&cp.args, "reset", "--hard", NULL);
288
cp.env = child_env.argv;
289
ret = run_command(&cp);
290
if (!ret) {