path: root/builtin
diff options
authorDerrick Stolee <>2020-10-15 17:22:03 (GMT)
committerJunio C Hamano <>2020-10-16 15:36:42 (GMT)
commit61f7a383d3b9a7306f1fd44a8dfa070deacc0752 (patch)
treea3a32480d13bc5a104b0067039b45f46806d61a1 /builtin
parenta4cb1a2339c1aa4ba71ebc6d2b07d537e1071124 (diff)
maintenance: use 'incremental' strategy by default
The 'git maintenance (register|start)' subcommands add the current repository to the global Git config so maintenance will operate on that repository. It does not specify what maintenance should occur or how often. To make it simple for users to start background maintenance with a recommended schedlue, update the 'maintenance.strategy' config option in both the 'register' and 'start' subcommands. This allows users to customize beyond the defaults using individual 'maintenance.<task>.schedule' options, but also the user can opt-out of this strategy using 'maintenance.strategy=none'. Helped-by: Martin Ă…gren <> Signed-off-by: Derrick Stolee <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin')
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index a8248e7..e3098ef 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1434,6 +1434,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
static int maintenance_register(void)
+ char *config_value;
struct child_process config_set = CHILD_PROCESS_INIT;
struct child_process config_get = CHILD_PROCESS_INIT;
@@ -1441,6 +1442,15 @@ static int maintenance_register(void)
if (!the_repository || !the_repository->gitdir)
return 0;
+ /* Disable foreground maintenance */
+ git_config_set("", "false");
+ /* Set maintenance strategy, if unset */
+ if (!git_config_get_string("maintenance.strategy", &config_value))
+ free(config_value);
+ else
+ git_config_set("maintenance.strategy", "incremental");
config_get.git_cmd = 1;
strvec_pushl(&config_get.args, "config", "--global", "--get", "maintenance.repo",
the_repository->worktree ? the_repository->worktree