From 24fc2cde6448233dbbe1f6695577a49679ccc98b Mon Sep 17 00:00:00 2001 From: William Sprent Date: Mon, 27 Mar 2023 07:55:02 +0000 Subject: builtin/sparse-checkout: remove NEED_WORK_TREE flag In preparation for adding a sub-command to 'sparse-checkout' that can be run in a bare repository, remove the 'NEED_WORK_TREE' flag from its entry in the 'commands' array of 'git.c'. To avoid that this changes any behaviour, add calls to 'setup_work_tree()' to all of the 'sparse-checkout' sub-commands and add tests that verify that 'sparse-checkout ' still fail with a clear error message telling the user that the command needs a work tree. Signed-off-by: William Sprent Signed-off-by: Junio C Hamano --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git.c') diff --git a/git.c b/git.c index ae2134f29a..9dee94a4b3 100644 --- a/git.c +++ b/git.c @@ -584,7 +584,7 @@ static struct cmd_struct commands[] = { { "show-branch", cmd_show_branch, RUN_SETUP }, { "show-index", cmd_show_index, RUN_SETUP_GENTLY }, { "show-ref", cmd_show_ref, RUN_SETUP }, - { "sparse-checkout", cmd_sparse_checkout, RUN_SETUP | NEED_WORK_TREE }, + { "sparse-checkout", cmd_sparse_checkout, RUN_SETUP }, { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE }, { "stash", cmd_stash, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, -- cgit v1.2.3