From 9df3be8e2e7e2c9bf200de4bcfbd4e690a57f033 Mon Sep 17 00:00:00 2001 From: Burak Kaan Karaçay Date: Thu, 12 Mar 2026 17:44:37 +0300 Subject: run-command: wean auto_maintenance() functions off the_repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prepare_auto_maintenance() relies on the_repository to read configurations. Since run_auto_maintenance() calls prepare_auto_maintenance(), it also implicitly depends the_repository. Add 'struct repository *' as a parameter to both functions and update all callers to pass the_repository. With no global repository dependencies left in this file, remove the USE_THE_REPOSITORY_VARIABLE macro. Suggested-by: Patrick Steinhardt Signed-off-by: Burak Kaan Karaçay Signed-off-by: Junio C Hamano --- builtin/am.c | 2 +- builtin/commit.c | 2 +- builtin/fetch.c | 2 +- builtin/merge.c | 2 +- builtin/rebase.c | 4 +++- builtin/receive-pack.c | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) (limited to 'builtin') diff --git a/builtin/am.c b/builtin/am.c index e0c767e223..9d0b51c651 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1937,7 +1937,7 @@ next: */ if (!state->rebasing) { am_destroy(state); - run_auto_maintenance(state->quiet); + run_auto_maintenance(the_repository, state->quiet); } } diff --git a/builtin/commit.c b/builtin/commit.c index 844bdcc728..7b23c1f883 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1958,7 +1958,7 @@ int cmd_commit(int argc, git_test_write_commit_graph_or_die(the_repository->objects->sources); repo_rerere(the_repository, 0); - run_auto_maintenance(quiet); + run_auto_maintenance(the_repository, quiet); run_commit_hook(use_editor, repo_get_index_file(the_repository), NULL, "post-commit", NULL); if (amend && !no_post_rewrite) { diff --git a/builtin/fetch.c b/builtin/fetch.c index 8a36cf67b5..4795b2a13c 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2873,7 +2873,7 @@ int cmd_fetch(int argc, if (opt_val != 0) git_config_push_parameter("maintenance.incremental-repack.auto=-1"); } - run_auto_maintenance(verbosity < 0); + run_auto_maintenance(the_repository, verbosity < 0); } cleanup: diff --git a/builtin/merge.c b/builtin/merge.c index 4e456a381c..2cbce56f8d 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -506,7 +506,7 @@ static void finish(struct commit *head_commit, * We ignore errors in 'gc --auto', since the * user should see them. */ - run_auto_maintenance(verbosity < 0); + run_auto_maintenance(the_repository, verbosity < 0); } } if (new_head && show_diffstat) { diff --git a/builtin/rebase.c b/builtin/rebase.c index c487e10907..8c1316db38 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -562,7 +562,9 @@ static int finish_rebase(struct rebase_options *opts) * We ignore errors in 'git maintenance run --auto', since the * user should see them. */ - run_auto_maintenance(!(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE))); + run_auto_maintenance(the_repository, + !(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE))); + if (opts->type == REBASE_MERGE) { struct replay_opts replay = REPLAY_OPTS_INIT; diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index d6225df890..e34edff406 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2727,7 +2727,7 @@ int cmd_receive_pack(int argc, if (auto_gc) { struct child_process proc = CHILD_PROCESS_INIT; - if (prepare_auto_maintenance(1, &proc)) { + if (prepare_auto_maintenance(the_repository, 1, &proc)) { proc.no_stdin = 1; proc.stdout_to_stderr = 1; proc.err = use_sideband ? -1 : 0; -- cgit v1.3