@matheusbsbs / matheus-bagliano / commits / 1942d48380
Fork 0

maintenance: optionally skip --auto process

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>

Derrick Stolee committed Aug 28, 2020 at 15:45 UTC 1942d48380fec53f76361e9adebef15b5db9628a
3 files changed +24
Documentation/config/maintenance.txt
+5
@@ -1,3 +1,8 @@
1 +maintenance.auto::
2 + This boolean config option controls whether some commands run
3 + `git maintenance run --auto` after doing their normal work. Defaults
4 + to true.
5 +
6 maintenance.<task>.enabled::
7 This boolean config option controls whether the maintenance task
8 with name `<task>` is run when no `--task` option is specified to
run-command.c
+6
@@ -7,6 +7,7 @@
7 #include "strbuf.h"
8 #include "string-list.h"
9 #include "quote.h"
10 +#include "config.h"
11
12 void child_process_init(struct child_process *child)
13 {
@@ -1868,8 +1869,13 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
1869
1870 int run_auto_maintenance(int quiet)
1871 {
1872 + int enabled;
1873 struct child_process maint = CHILD_PROCESS_INIT;
1874
1875 + if (!git_config_get_bool("maintenance.auto", &enabled) &&
1876 + !enabled)
1877 + return 0;
1878 +
1879 maint.git_cmd = 1;
1880 strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
1881 strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");
t/t7900-maintenance.sh
+13
@@ -28,6 +28,19 @@ test_expect_success 'run [--auto|--quiet]' '
28 test_subcommand git gc --no-quiet <run-no-quiet.txt
29 '
30
31 +test_expect_success 'maintenance.auto config option' '
32 + GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 &&
33 + test_subcommand git maintenance run --auto --quiet <default &&
34 + GIT_TRACE2_EVENT="$(pwd)/true" \
35 + git -c maintenance.auto=true \
36 + commit --quiet --allow-empty -m 2 &&
37 + test_subcommand git maintenance run --auto --quiet <true &&
38 + GIT_TRACE2_EVENT="$(pwd)/false" \
39 + git -c maintenance.auto=false \
40 + commit --quiet --allow-empty -m 3 &&
41 + test_subcommand ! git maintenance run --auto --quiet <false
42 +'
43 +
44 test_expect_success 'maintenance.<task>.enabled' '
45 git config maintenance.gc.enabled false &&
46 git config maintenance.commit-graph.enabled true &&