mirror of
https://github.com/git/git.git
synced 2026-08-05 07:31:02 +00:00
run-command: wean auto_maintenance() functions off the_repository
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 <ps@pks.im> Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
05c324b92f
commit
9df3be8e2e
@@ -1,4 +1,3 @@
|
||||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
||||
|
||||
#include "git-compat-util.h"
|
||||
@@ -1937,11 +1936,12 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
|
||||
trace2_region_leave(tr2_category, tr2_label, NULL);
|
||||
}
|
||||
|
||||
int prepare_auto_maintenance(int quiet, struct child_process *maint)
|
||||
int prepare_auto_maintenance(struct repository *r, int quiet,
|
||||
struct child_process *maint)
|
||||
{
|
||||
int enabled, auto_detach;
|
||||
|
||||
if (!repo_config_get_bool(the_repository, "maintenance.auto", &enabled) &&
|
||||
if (!repo_config_get_bool(r, "maintenance.auto", &enabled) &&
|
||||
!enabled)
|
||||
return 0;
|
||||
|
||||
@@ -1950,12 +1950,12 @@ int prepare_auto_maintenance(int quiet, struct child_process *maint)
|
||||
* honoring `gc.autoDetach`. This is somewhat weird, but required to
|
||||
* retain behaviour from when we used to run git-gc(1) here.
|
||||
*/
|
||||
if (repo_config_get_bool(the_repository, "maintenance.autodetach", &auto_detach) &&
|
||||
repo_config_get_bool(the_repository, "gc.autodetach", &auto_detach))
|
||||
if (repo_config_get_bool(r, "maintenance.autodetach", &auto_detach) &&
|
||||
repo_config_get_bool(r, "gc.autodetach", &auto_detach))
|
||||
auto_detach = git_env_bool("GIT_TEST_MAINT_AUTO_DETACH", true);
|
||||
|
||||
maint->git_cmd = 1;
|
||||
maint->odb_to_close = the_repository->objects;
|
||||
maint->odb_to_close = r->objects;
|
||||
strvec_pushl(&maint->args, "maintenance", "run", "--auto", NULL);
|
||||
strvec_push(&maint->args, quiet ? "--quiet" : "--no-quiet");
|
||||
strvec_push(&maint->args, auto_detach ? "--detach" : "--no-detach");
|
||||
@@ -1963,10 +1963,10 @@ int prepare_auto_maintenance(int quiet, struct child_process *maint)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int run_auto_maintenance(int quiet)
|
||||
int run_auto_maintenance(struct repository *r, int quiet)
|
||||
{
|
||||
struct child_process maint = CHILD_PROCESS_INIT;
|
||||
if (!prepare_auto_maintenance(quiet, &maint))
|
||||
if (!prepare_auto_maintenance(r, quiet, &maint))
|
||||
return 0;
|
||||
return run_command(&maint);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user