Skip to content

Commit 882ce0c

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9816e24 commit 882ce0c

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

Documentation/scalar.adoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]
12-
[--[no-]src] <url> [<enlistment>]
12+
[--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]
1313
scalar list
1414
scalar register [--[no-]maintenance] [<enlistment>]
1515
scalar unregister [<enlistment>]
@@ -97,6 +97,11 @@ cloning. If the HEAD at the remote did not point at any branch when
9797
A sparse-checkout is initialized by default. This behavior can be
9898
turned off via `--full-clone`.
9999

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.
104+
100105
List
101106
~~~~
102107

scalar.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static int cmd_clone(int argc, const char **argv)
426426
const char *branch = NULL;
427427
char *branch_to_free = NULL;
428428
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;
430430
struct option clone_options[] = {
431431
OPT_STRING('b', "branch", &branch, N_("<branch>"),
432432
N_("branch to checkout after clone")),
@@ -439,11 +439,13 @@ static int cmd_clone(int argc, const char **argv)
439439
N_("create repository within 'src' directory")),
440440
OPT_BOOL(0, "tags", &tags,
441441
N_("specify if tags should be fetched during clone")),
442+
OPT_BOOL(0, "maintenance", &maintenance,
443+
N_("specify if background maintenance should be enabled")),
442444
OPT_END(),
443445
};
444446
const char * const clone_usage[] = {
445447
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>]"),
447449
NULL
448450
};
449451
const char *url;
@@ -565,7 +567,8 @@ static int cmd_clone(int argc, const char **argv)
565567
if (res)
566568
goto cleanup;
567569

568-
res = register_dir(1);
570+
/* If --no-maintenance, then skip maintenance command entirely. */
571+
res = register_dir(maintenance);
569572

570573
cleanup:
571574
free(branch_to_free);

t/t9211-scalar-clone.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,16 @@ test_expect_success 'progress without tty' '
177177
test_expect_success 'scalar clone warns when background maintenance fails' '
178178
GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
179179
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
181190
'
182191

183192
test_expect_success '`scalar clone --no-src`' '

0 commit comments

Comments
 (0)