Skip to content

Commit 1292825

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 <stolee@gmail.com>
1 parent de1a0e0 commit 1292825

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

Documentation/scalar.adoc

Lines changed: 11 additions & 3 deletions
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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,14 +670,16 @@ static int remove_deleted_enlistment(struct strbuf *path)
670670

671671
static int cmd_reconfigure(int argc, const char **argv)
672672
{
673-
int all = 0;
673+
int all = 0, maintenance = 1;
674674
struct option options[] = {
675675
OPT_BOOL('a', "all", &all,
676676
N_("reconfigure all registered enlistments")),
677+
OPT_BOOL(0, "maintenance", &maintenance,
678+
N_("specify if background maintenance should be enabled")),
677679
OPT_END(),
678680
};
679681
const char * const usage[] = {
680-
N_("scalar reconfigure [--all | <enlistment>]"),
682+
N_("scalar reconfigure [--[no-]maintenance] [--all | <enlistment>]"),
681683
NULL
682684
};
683685
struct string_list scalar_repos = STRING_LIST_INIT_DUP;
@@ -761,7 +763,8 @@ static int cmd_reconfigure(int argc, const char **argv)
761763
the_repository = old_repo;
762764
repo_clear(&r);
763765

764-
if (toggle_maintenance(1) >= 0)
766+
if (maintenance &&
767+
toggle_maintenance(1) >= 0)
765768
succeeded = 1;
766769

767770
loop_end:

t/t9210-scalar.sh

Lines changed: 6 additions & 1 deletion
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)