git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/7] maintenance: optionally skip --auto process

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 19, 2020, 17:16 UTC
Message-ID
<90de25d1287595fdedc9dcd194a2e0ac120d4aad.1597857409.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.680.git.1597857408.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>

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>
---
 Documentation/config/maintenance.txt |  5 +++++
 run-command.c                        |  8 ++++++++
 t/t7900-maintenance.sh               | 13 +++++++++++++
 3 files changed, 26 insertions(+)
diff --git a/Documentation/config/maintenance.txt b/Documentation/config/maintenance.txt
index a0706d8f09..06db758172 100644
--- a/Documentation/config/maintenance.txt
+++ b/Documentation/config/maintenance.txt
@@ -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
diff --git a/run-command.c b/run-command.c
index 2ee59acdc8..9c9d5d7f98 100644
--- a/run-command.c
+++ b/run-command.c
@@ -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,15 @@ 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) {
+		    fprintf(stderr, "enabled: %d\n", enabled);
+		return 0;
+	    }
+
 	maint.git_cmd = 1;
 	strvec_pushl(&maint.args, "maintenance", "run", "--auto", NULL);
 	strvec_push(&maint.args, quiet ? "--quiet" : "--no-quiet");
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 6f878b0141..e0ba19e1ff 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -26,6 +26,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 &&
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Đoàn Trần Công Danh
Message 2 of 41 in “[RFC] Maintenance III: background maintenance”
  1. 0/7 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 19, 2020
  2. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 19, 2020
  3. Đoàn Trần Công DanhAug 20, 2020
  4. Derrick StoleeAug 20, 2020
  5. 4/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 19, 2020
  6. Đoàn Trần Công DanhAug 20, 2020
  7. 3/7 maintenance: add --scheduled option and configDerrick Stolee via GitGitGadget, Aug 19, 2020
  8. Đoàn Trần Công DanhAug 20, 2020
  9. Derrick StoleeAug 24, 2020
  10. 5/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 19, 2020
  11. 6/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 19, 2020
  12. 7/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 19, 2020
  13. 0/7 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 25, 2020
  14. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 25, 2020
  15. Junio C HamanoAug 25, 2020
  16. Derrick StoleeAug 26, 2020
  17. Junio C HamanoAug 26, 2020
  18. 2/7 maintenance: store the "last run" time in configDerrick Stolee via GitGitGadget, Aug 25, 2020
  19. Junio C HamanoAug 25, 2020
  20. Derrick StoleeAug 26, 2020
  21. Junio C HamanoAug 26, 2020
  22. Derrick StoleeAug 27, 2020
  23. 3/7 maintenance: add --scheduled option and configDerrick Stolee via GitGitGadget, Aug 25, 2020
  24. Junio C HamanoAug 25, 2020
  25. Derrick StoleeAug 26, 2020
  26. Derrick StoleeAug 27, 2020
  27. 4/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 25, 2020
  28. Junio C HamanoAug 25, 2020
  29. Derrick StoleeAug 26, 2020
  30. 6/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 25, 2020
  31. 7/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 25, 2020
  32. 5/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 25, 2020
  33. 0/6 [RFC] Maintenance III: background maintenanceDerrick Stolee via GitGitGadget, Aug 28, 2020
  34. 2/6 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Aug 28, 2020
  35. 4/6 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Aug 28, 2020
  36. 1/6 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Aug 28, 2020
  37. 5/6 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Aug 28, 2020
  38. 6/6 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Aug 28, 2020
  39. 3/6 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Aug 28, 2020
  40. Michal SuchánekAug 26, 2020
  41. Đoàn Trần Công DanhAug 20, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.