From: Matthew Hughes <matthewhughes934@gmail•com>
To: git@vger•kernel.org
Cc: Matthew Hughes <matthewhughes934@gmail•com>
Subject: [RFC PATCH 1/1] maintenance: add config option for config-file
Date: Thu, 18 Dec 2025 18:48:19 +0000 [thread overview]
Message-ID: <20251218184751.31209-2-matthewhughes934@gmail.com> (raw)
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
next prev parent reply other threads:[~2025-12-18 18:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 18:48 [RFC PATCH 0/1] maintenance: add config option for config-file Matthew Hughes
2025-12-18 18:48 ` Matthew Hughes [this message]
2025-12-19 7:18 ` [RFC PATCH 1/1] " Patrick Steinhardt
2025-12-19 8:27 ` Junio C Hamano
2025-12-22 8:26 ` Matthew Hughes
2025-12-22 21:51 ` D. Ben Knoble
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251218184751.31209-2-matthewhughes934@gmail.com \
--to=matthewhughes934@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox