Skip to content

Commit 6fac9c4

Browse files
committed
scalar reconfigure: add --no-maintenance option
When users want to enable the latest and greatest configuration options recommended by Scalar after a Git upgrade, 'scalar reconfigure --all' is a great option that iterates over all repos in the multi-valued 'scalar.repos' config key. However, this feature previously forced users to enable background maintenance. In some environments this is not preferred. Add a new --[no-]maintenance option to 'scalar reconfigure' that avoids running 'git maintenance start' on these enlistments. Signed-off-by: Derrick Stolee <[email protected]>
1 parent e52b128 commit 6fac9c4

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

Documentation/scalar.adoc

+11-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ scalar list
1414
scalar register [--[no-]maintenance] [<enlistment>]
1515
scalar unregister [<enlistment>]
1616
scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>]
17-
scalar reconfigure [ --all | <enlistment> ]
17+
scalar reconfigure [--[no-]maintenance] [ --all | <enlistment> ]
1818
scalar diagnose [<enlistment>]
1919
scalar delete <enlistment>
2020

@@ -160,8 +160,16 @@ After a Scalar upgrade, or when the configuration of a Scalar enlistment
160160
was somehow corrupted or changed by mistake, this subcommand allows to
161161
reconfigure the enlistment.
162162

163-
With the `--all` option, all enlistments currently registered with Scalar
164-
will be reconfigured. Use this option after each Scalar upgrade.
163+
--all::
164+
When `--all` is specified, reconfigure all enlistments currently
165+
registered with Scalar by the `scalar.repo` config key. Use this
166+
option after each upgrade to get the latest features.
167+
168+
--[no-]maintenance::
169+
By default, Scalar configures the enlistment to use Git's
170+
background maintenance feature. Use the `--no-maintenance` to skip
171+
this configuration and leave the repositories in whatever state is
172+
currently configured.
165173

166174
Diagnose
167175
~~~~~~~~

scalar.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -667,14 +667,16 @@ static int remove_deleted_enlistment(struct strbuf *path)
667667

668668
static int cmd_reconfigure(int argc, const char **argv)
669669
{
670-
int all = 0;
670+
int all = 0, maintenance = 1;
671671
struct option options[] = {
672672
OPT_BOOL('a', "all", &all,
673673
N_("reconfigure all registered enlistments")),
674+
OPT_BOOL(0, "maintenance", &maintenance,
675+
N_("specify if background maintenance should be enabled")),
674676
OPT_END(),
675677
};
676678
const char * const usage[] = {
677-
N_("scalar reconfigure [--all | <enlistment>]"),
679+
N_("scalar reconfigure [--[no-]maintenance] [--all | <enlistment>]"),
678680
NULL
679681
};
680682
struct string_list scalar_repos = STRING_LIST_INIT_DUP;
@@ -758,7 +760,8 @@ static int cmd_reconfigure(int argc, const char **argv)
758760
the_repository = old_repo;
759761
repo_clear(&r);
760762

761-
if (toggle_maintenance(1) >= 0)
763+
if (maintenance &&
764+
toggle_maintenance(1) >= 0)
762765
succeeded = 1;
763766

764767
loop_end:

t/t9210-scalar.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ test_expect_success 'scalar reconfigure' '
210210
GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a &&
211211
test_path_is_file one/src/cron.txt &&
212212
test true = "$(git -C one/src config core.preloadIndex)" &&
213-
test_subcommand git maintenance start <reconfigure
213+
test_subcommand git maintenance start <reconfigure &&
214+
test_subcommand ! git maintenance unregister --force <reconfigure &&
215+
216+
GIT_TRACE2_EVENT="$(pwd)/reconfigure-maint" scalar reconfigure --no-maintenance -a &&
217+
test_subcommand ! git maintenance start <reconfigure-maint &&
218+
test_subcommand ! git maintenance unregister --force <reconfigure-maint
214219
'
215220

216221
test_expect_success 'scalar reconfigure --all with includeIf.onbranch' '

0 commit comments

Comments
 (0)