]> git.ipfire.org Git - thirdparty/git.git/commitdiff
maintenance: optionally skip --auto process
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 28 Aug 2020 15:45:12 +0000 (15:45 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Sep 2020 17:59:44 +0000 (10:59 -0700)
Some commands run 'git maintenance run --auto --[no-]quiet' after doing
their normal work, as a way to keep repositories clean as they are used.
Currently, users who do not want this maintenance to occur would set the
'gc.auto' config option to 0 to avoid the 'gc' task from running.
However, this does not stop the extra process invocation. On Windows,
this extra process invocation can be more expensive than necessary.

Allow users to drop this extra process by setting 'maintenance.auto' to
'false'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/maintenance.txt
run-command.c
t/t7900-maintenance.sh

index a0706d8f098becab7b5df71c77f718b03cc9c1a2..06db7581726211221277fd53f140456146dc49db 100644 (file)
@@ -1,3 +1,8 @@
+maintenance.auto::
+       This boolean config option controls whether some commands run
+       `git maintenance run --auto` after doing their normal work. Defaults
+       to true.
+
 maintenance.<task>.enabled::
        This boolean config option controls whether the maintenance task
        with name `<task>` is run when no `--task` option is specified to
index 2ee59acdc8c828ad81ccb7526bd7f23fc460d095..ea4d0fb4b154c89a0fcd12d29e41ffcbb2af0302 100644 (file)
@@ -7,6 +7,7 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "quote.h"
+#include "config.h"
 
 void child_process_init(struct child_process *child)
 {
@@ -1868,8 +1869,13 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
 
 int run_auto_maintenance(int quiet)
 {
+       int enabled;
        struct child_process maint = CHILD_PROCESS_INIT;
 
+       if (!git_config_get_bool("maintenance.auto", &enabled) &&
+           !enabled)
+               return 0;
+
        maint.git_cmd = 1;
        strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
        strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");
index 55116c2f041e31a8d8e219ab9a81cb2b0d44cea7..c7caaa7a55f9978c4d17a88ae54f42e3a2c9fe12 100755 (executable)
@@ -28,6 +28,19 @@ test_expect_success 'run [--auto|--quiet]' '
        test_subcommand git gc --no-quiet <run-no-quiet.txt
 '
 
+test_expect_success 'maintenance.auto config option' '
+       GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 &&
+       test_subcommand git maintenance run --auto --quiet <default &&
+       GIT_TRACE2_EVENT="$(pwd)/true" \
+               git -c maintenance.auto=true \
+               commit --quiet --allow-empty -m 2 &&
+       test_subcommand git maintenance run --auto --quiet  <true &&
+       GIT_TRACE2_EVENT="$(pwd)/false" \
+               git -c maintenance.auto=false \
+               commit --quiet --allow-empty -m 3 &&
+       test_subcommand ! git maintenance run --auto --quiet  <false
+'
+
 test_expect_success 'maintenance.<task>.enabled' '
        git config maintenance.gc.enabled false &&
        git config maintenance.commit-graph.enabled true &&