Git fork

scalar clone: add --no-maintenance option

When creating a new enlistment via 'scalar clone', the default is to set
up situations that work for most user scenarios. Background maintenance
is one of those highly-recommended options for most users.

However, when using 'scalar clone' to create an enlistment in a
different situation, such as prepping a VM image, it may be valuable to
disable background maintenance so the manual maintenance steps do not
get blocked by concurrent background maintenance activities.

Add a new --no-maintenance option to 'scalar clone'.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Derrick Stolee and committed by
Junio C Hamano
882ce0c4 9816e24a

+22 -5
+6 -1
Documentation/scalar.adoc
··· 9 9 -------- 10 10 [verse] 11 11 scalar clone [--single-branch] [--branch <main-branch>] [--full-clone] 12 - [--[no-]src] <url> [<enlistment>] 12 + [--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>] 13 13 scalar list 14 14 scalar register [--[no-]maintenance] [<enlistment>] 15 15 scalar unregister [<enlistment>] ··· 96 96 --[no-]full-clone:: 97 97 A sparse-checkout is initialized by default. This behavior can be 98 98 turned off via `--full-clone`. 99 + 100 + --[no-]maintenance:: 101 + By default, `scalar clone` configures the enlistment to use Git's 102 + background maintenance feature. Use the `--no-maintenance` to skip 103 + this configuration. 99 104 100 105 List 101 106 ~~~~
+6 -3
scalar.c
··· 426 426 const char *branch = NULL; 427 427 char *branch_to_free = NULL; 428 428 int full_clone = 0, single_branch = 0, show_progress = isatty(2); 429 - int src = 1, tags = 1; 429 + int src = 1, tags = 1, maintenance = 1; 430 430 struct option clone_options[] = { 431 431 OPT_STRING('b', "branch", &branch, N_("<branch>"), 432 432 N_("branch to checkout after clone")), ··· 439 439 N_("create repository within 'src' directory")), 440 440 OPT_BOOL(0, "tags", &tags, 441 441 N_("specify if tags should be fetched during clone")), 442 + OPT_BOOL(0, "maintenance", &maintenance, 443 + N_("specify if background maintenance should be enabled")), 442 444 OPT_END(), 443 445 }; 444 446 const char * const clone_usage[] = { 445 447 N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n" 446 - "\t[--[no-]src] [--[no-]tags] <url> [<enlistment>]"), 448 + "\t[--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]"), 447 449 NULL 448 450 }; 449 451 const char *url; ··· 565 567 if (res) 566 568 goto cleanup; 567 569 568 - res = register_dir(1); 570 + /* If --no-maintenance, then skip maintenance command entirely. */ 571 + res = register_dir(maintenance); 569 572 570 573 cleanup: 571 574 free(branch_to_free);
+10 -1
t/t9211-scalar-clone.sh
··· 177 177 test_expect_success 'scalar clone warns when background maintenance fails' ' 178 178 GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \ 179 179 scalar clone "file://$(pwd)/to-clone" maint-fail 2>err && 180 - grep "could not turn on maintenance" err 180 + grep "could not toggle maintenance" err 181 + ' 182 + 183 + test_expect_success 'scalar clone --no-maintenance' ' 184 + GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \ 185 + GIT_TRACE2_EVENT="$(pwd)/no-maint.event" \ 186 + GIT_TRACE2_EVENT_DEPTH=100 \ 187 + scalar clone --no-maintenance "file://$(pwd)/to-clone" no-maint 2>err && 188 + ! grep "could not toggle maintenance" err && 189 + test_subcommand ! git maintenance unregister --force <no-maint.event 181 190 ' 182 191 183 192 test_expect_success '`scalar clone --no-src`' '