Skip to content

Commit 7ab1914

Browse files
committed
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]>
1 parent 4910bac commit 7ab1914

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static int cmd_clone(int argc, const char **argv)
411411
const char *branch = NULL;
412412
char *branch_to_free = NULL;
413413
int full_clone = 0, single_branch = 0, show_progress = isatty(2);
414-
int src = 1, tags = 1;
414+
int src = 1, tags = 1, maintenance = 1;
415415
struct option clone_options[] = {
416416
OPT_STRING('b', "branch", &branch, N_("<branch>"),
417417
N_("branch to checkout after clone")),
@@ -424,11 +424,13 @@ static int cmd_clone(int argc, const char **argv)
424424
N_("create repository within 'src' directory")),
425425
OPT_BOOL(0, "tags", &tags,
426426
N_("specify if tags should be fetched during clone")),
427+
OPT_BOOL(0, "maintenance", &maintenance,
428+
N_("specify if background maintenance should be enabled")),
427429
OPT_END(),
428430
};
429431
const char * const clone_usage[] = {
430432
N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n"
431-
"\t[--[no-]src] [--[no-]tags] <url> [<enlistment>]"),
433+
"\t[--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]"),
432434
NULL
433435
};
434436
const char *url;
@@ -550,7 +552,7 @@ static int cmd_clone(int argc, const char **argv)
550552
if (res)
551553
goto cleanup;
552554

553-
res = register_dir(1);
555+
res = register_dir(maintenance);
554556

555557
cleanup:
556558
free(branch_to_free);

t/t9211-scalar-clone.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ test_expect_success 'scalar clone warns when background maintenance fails' '
180180
grep "could not turn on maintenance" err
181181
'
182182

183+
test_expect_success 'scalar clone --no-maintenance' '
184+
GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
185+
scalar clone --no-maintenance "file://$(pwd)/to-clone" no-maint 2>err &&
186+
! grep "could not turn on maintenance" err
187+
'
188+
183189
test_expect_success '`scalar clone --no-src`' '
184190
scalar clone --src "file://$(pwd)/to-clone" with-src &&
185191
scalar clone --no-src "file://$(pwd)/to-clone" without-src &&

0 commit comments

Comments
 (0)