diff options
| author | Derrick Stolee <stolee@gmail.com> | 2025-05-07 01:50:37 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-07 14:04:32 -0700 |
| commit | a34fef86e09f4dfe8b1198dd56e0631d24302b0e (patch) | |
| tree | 1fe94344d8e391ef8fffc6b5b3cd166ca78f8095 /scalar.c | |
| parent | 882ce0c475167039ca368d34699e113042ea47ae (diff) | |
| download | git-a34fef86e09f4dfe8b1198dd56e0631d24302b0e.tar.xz | |
scalar reconfigure: add --maintenance=<mode> 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 --maintenance=<mode> option to 'scalar reconfigure' that
provides options for enabling (default), disabling, or leaving
background maintenance config as-is.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'scalar.c')
| -rw-r--r-- | scalar.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -668,13 +668,19 @@ static int remove_deleted_enlistment(struct strbuf *path) static int cmd_reconfigure(int argc, const char **argv) { int all = 0; + const char *maintenance_str = NULL; + int maintenance = 1; /* Enable maintenance by default. */ + struct option options[] = { OPT_BOOL('a', "all", &all, N_("reconfigure all registered enlistments")), + OPT_STRING(0, "maintenance", &maintenance_str, + N_("<mode>"), + N_("signal how to adjust background maintenance")), OPT_END(), }; const char * const usage[] = { - N_("scalar reconfigure [--all | <enlistment>]"), + N_("scalar reconfigure [--maintenance=<mode>] [--all | <enlistment>]"), NULL }; struct string_list scalar_repos = STRING_LIST_INIT_DUP; @@ -694,6 +700,18 @@ static int cmd_reconfigure(int argc, const char **argv) usage_msg_opt(_("--all or <enlistment>, but not both"), usage, options); + if (maintenance_str) { + if (!strcmp(maintenance_str, "enable")) + maintenance = 1; + else if (!strcmp(maintenance_str, "disable")) + maintenance = 0; + else if (!strcmp(maintenance_str, "keep")) + maintenance = -1; + else + die(_("unknown mode for --maintenance option: %s"), + maintenance_str); + } + git_config(get_scalar_repos, &scalar_repos); for (size_t i = 0; i < scalar_repos.nr; i++) { @@ -758,7 +776,8 @@ static int cmd_reconfigure(int argc, const char **argv) the_repository = old_repo; repo_clear(&r); - if (toggle_maintenance(1) >= 0) + if (maintenance >= 0 && + toggle_maintenance(maintenance) >= 0) succeeded = 1; loop_end: |
