summaryrefslogtreecommitdiff
path: root/builtin/gc.c
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2023-08-10 20:39:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-08-10 21:04:17 (GMT)
commit69ecfcacfd136810f2343b548174efe9ae3fdead (patch)
treeac07627110e9cc44534d00729d4d5d3ca45a5521 /builtin/gc.c
parentc97ec0378b97036c62492678931a297a4498d12c (diff)
downloadgit-69ecfcacfd136810f2343b548174efe9ae3fdead.zip
git-69ecfcacfd136810f2343b548174efe9ae3fdead.tar.gz
git-69ecfcacfd136810f2343b548174efe9ae3fdead.tar.bz2
maintenance: update schedule before config
When running 'git maintenance start', the current pattern is to configure global config settings to enable maintenance on the current repository and set 'maintenance.auto' to false and _then_ to set up the schedule with the system scheduler. This has a problematic error condition: if the scheduler fails to initialize, the repository still will not use automatic maintenance due to the 'maintenance.auto' setting. Fix this gap by swapping the order of operations. If Git fails to initialize maintenance, then the config changes should never happen. Reported-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 6f8df36..fe5f871 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -2728,9 +2728,12 @@ static int maintenance_start(int argc, const char **argv, const char *prefix)
opts.scheduler = resolve_scheduler(opts.scheduler);
validate_scheduler(opts.scheduler);
+ if (update_background_schedule(&opts, 1))
+ die(_("failed to set up maintenance schedule"));
+
if (maintenance_register(ARRAY_SIZE(register_args)-1, register_args, NULL))
warning(_("failed to add repo to global config"));
- return update_background_schedule(&opts, 1);
+ return 0;
}
static const char *const builtin_maintenance_stop_usage[] = {