Skip to content

Commit c34d097

Browse files
committed
scalar reconfigure: add --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. Create a new --[no-]maintenance flag for this subcommand, allowing users to enable or disable background maintenance. This presents a behavior change in the default case, removing adjustments to background maintenance unless one of the --maintenance or --no-maintenance options is specified. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent e52b128 commit c34d097

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

Documentation/scalar.adoc

Lines changed: 10 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,15 @@ 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+
Specify if maintenance should be enabled or disabled for each
170+
enlistment being reconfigured. Default behavior will not adjust
171+
the maintenance configuration.
165172

166173
Diagnose
167174
~~~~~~~~

scalar.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,13 +668,17 @@ static int remove_deleted_enlistment(struct strbuf *path)
668668
static int cmd_reconfigure(int argc, const char **argv)
669669
{
670670
int all = 0;
671+
int maintenance = -1;
672+
671673
struct option options[] = {
672674
OPT_BOOL('a', "all", &all,
673675
N_("reconfigure all registered enlistments")),
676+
OPT_BOOL(0, "maintenance", &maintenance,
677+
N_("enable or disable background maintenance")),
674678
OPT_END(),
675679
};
676680
const char * const usage[] = {
677-
N_("scalar reconfigure [--all | <enlistment>]"),
681+
N_("scalar reconfigure [--[no-]maintenance] [--all | <enlistment>]"),
678682
NULL
679683
};
680684
struct string_list scalar_repos = STRING_LIST_INIT_DUP;
@@ -758,7 +762,8 @@ static int cmd_reconfigure(int argc, const char **argv)
758762
the_repository = old_repo;
759763
repo_clear(&r);
760764

761-
if (toggle_maintenance(1) >= 0)
765+
if (maintenance >= 0 &&
766+
toggle_maintenance(maintenance) >= 0)
762767
succeeded = 1;
763768

764769
loop_end:

t/t9210-scalar.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,21 @@ test_expect_success 'scalar reconfigure' '
207207
test true = "$(git -C one/src config core.preloadIndex)" &&
208208
git -C one/src config core.preloadIndex false &&
209209
rm one/src/cron.txt &&
210-
GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a &&
210+
GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a --maintenance &&
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-no-maint" \
217+
scalar reconfigure -a --no-maintenance &&
218+
test_subcommand ! git maintenance start <reconfigure-no-maint &&
219+
test_subcommand git maintenance unregister --force <reconfigure-no-maint &&
220+
221+
GIT_TRACE2_EVENT="$(pwd)/reconfigure-default" \
222+
scalar reconfigure -a &&
223+
test_subcommand ! git maintenance start <reconfigure-default &&
224+
test_subcommand ! git maintenance unregister --force <reconfigure-default
214225
'
215226

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

0 commit comments

Comments
 (0)