]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/gc.c
maintenance: use 'incremental' strategy by default
[thirdparty/git.git] / builtin / gc.c
index a8248e7a453a87f477f505b27e3edb43ba803042..e3098ef6a12896e4f4890a9f6d12c6ac7bed3eac 100644 (file)
@@ -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("maintenance.auto", "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