Skip to content

Commit 0ca560c

Browse files
sunshinecogitster
authored andcommitted
checkout: require worktree unconditionally
In order to allow linked worktree creation via "git checkout --to" from a bare repository, 3473ad0 (checkout: don't require a work tree when checking out into a new one, 2014-11-30) dropped git-checkout's unconditional NEED_WORK_TREE requirement and instead performed worktree setup conditionally based upon presence or absence of the --to option. Now that --to has been retired and git-checkout is no longer responsible for linked worktree creation, the NEED_WORK_TREE requirement can be re-instated. This effectively reverts 3473ad0, except for the tests it added which now check bare repository behavior of "git worktree add" instead. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b979d95 commit 0ca560c

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

builtin/checkout.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
12181218

12191219
opts.new_worktree_mode = getenv("GIT_CHECKOUT_NEW_WORKTREE") != NULL;
12201220

1221-
setup_work_tree();
1222-
12231221
if (conflict_style) {
12241222
opts.merge = 1; /* implied */
12251223
git_xmerge_config("merge.conflictstyle", conflict_style, NULL);

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static struct cmd_struct commands[] = {
383383
{ "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE },
384384
{ "check-mailmap", cmd_check_mailmap, RUN_SETUP },
385385
{ "check-ref-format", cmd_check_ref_format },
386-
{ "checkout", cmd_checkout, RUN_SETUP },
386+
{ "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
387387
{ "checkout-index", cmd_checkout_index,
388388
RUN_SETUP | NEED_WORK_TREE},
389389
{ "cherry", cmd_cherry, RUN_SETUP },

0 commit comments

Comments
 (0)