Skip to content

Commit

Permalink
worktree: populate via "git reset --hard" rather than "git checkout"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Sunshine authored and Junio C Hamano committed Jul 20, 2015
1 parent ed197a6 commit 1c56190
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions builtin/worktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ static int add_worktree(const char *path, const char *refname,

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

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

cp.argv = NULL;
argv_array_clear(&cp.args);
argv_array_push(&cp.args, "checkout");
argv_array_pushl(&cp.args, "reset", "--hard", NULL);
cp.env = child_env.argv;
ret = run_command(&cp);
if (!ret) {
Expand Down

0 comments on commit 1c56190

Please sign in to comment.