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

[RFC PATCH 1/1] maintenance: add config option for config-file

From
Matthew Hughes <matthewhughes934@gmail.com>
Date
Dec 18, 2025, 18:48 UTC
Message-ID
<20251218184751.31209-2-matthewhughes934@gmail.com>
In-Reply-To
<20251218184751.31209-1-matthewhughes934@gmail.com>

This is to allow splitting out this configuration from the global config file, e.g.:

    # in ~/.config/git/config
    [include]
        path = maintenance.config
    [maintenance]
        # use a separate files for reads/writes from
        # 'git maintenance {un,}register'
        configFile = ~/.config/git/maintenance.config
    # in ~/.config/git/maintenance.config
    [maintenance]
        repo = /path/to/some/repo
        repo = /path/to/another/repo

My motivation for this is that I track my global config in git, so I'd like to avoid changes in there that depend on specific repos/workflows that I'm working with.

Signed-off-by: Matthew Hughes <matthewhughes934@gmail.com>
---
 builtin/gc.c           |  8 ++++++++
 t/t7900-maintenance.sh | 13 +++++++++++++
 2 files changed, 21 insertions(+)
diff --git a/builtin/gc.c b/builtin/gc.c
index 92c6e7b954..257cceecf6 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -2124,6 +2124,10 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
 		usage_with_options(builtin_maintenance_register_usage,
 				   options);
 
+	if (config_file == NULL) {
+		repo_config_get_pathname(the_repository, "maintenance.configFile", &config_file);
+	}
+
 	/* Disable foreground maintenance */
 	repo_config_set(the_repository, "maintenance.auto", "false");
 
@@ -2194,6 +2198,10 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi
 		usage_with_options(builtin_maintenance_unregister_usage,
 				   options);
 
+	if (config_file == NULL) {
+		repo_config_get_pathname(the_repository, "maintenance.configFile", &config_file);
+	}
+
 	if (config_file) {
 		git_configset_init(&cs);
 		git_configset_add_file(&cs, config_file);
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 6b36f52df7..baad960051 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -1024,6 +1024,19 @@ test_expect_success 'register and unregister' '
 	git maintenance unregister --config-file ./other --force
 '
 
+test_expect_success 'register and unregister config from maintenance.configFile' '
+	test_when_finished git config --global --unset-all maintenance.configFile &&
+
+	git config set --global maintenance.configFile ./maintenance.config &&
+	git maintenance register &&
+	pwd >>expect &&
+	git config get --file ./maintenance.config maintenance.repo >actual &&
+	test_cmp expect actual &&
+
+	git maintenance unregister &&
+	test_must_be_empty ./maintenance.config
+'
+
 test_expect_success 'register with no value for maintenance.repo' '
 	cp .git/config .git/config.orig &&
 	test_when_finished mv .git/config.orig .git/config &&
-- 
2.52.0
Previous: Matthew HughesNext: Patrick Steinhardt
Message 2 of 6 in “maintenance: add config option for config-file”
  1. 0/1 maintenance: add config option for config-fileMatthew Hughes, Dec 18, 2025
  2. 1/1 maintenance: add config option for config-fileMatthew Hughes, Dec 18, 2025
  3. Patrick SteinhardtDec 19, 2025
  4. Junio C HamanoDec 19, 2025
  5. Matthew HughesDec 22, 2025
  6. D. Ben KnobleDec 22, 2025

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.