Merge branch 'bk/run-command-wo-the-repository'
The run_command() API lost its implicit dependencyon the singleton `the_repository` instance. * bk/run-command-wo-the-repository: run-command: wean auto_maintenance() functions off the_repository run-command: wean start_command() off the_repositorymaint
commit
a7a079c2c4
|
|
@ -1937,7 +1937,7 @@ next:
|
||||||
*/
|
*/
|
||||||
if (!state->rebasing) {
|
if (!state->rebasing) {
|
||||||
am_destroy(state);
|
am_destroy(state);
|
||||||
run_auto_maintenance(state->quiet);
|
run_auto_maintenance(the_repository, state->quiet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1958,7 +1958,7 @@ int cmd_commit(int argc,
|
||||||
git_test_write_commit_graph_or_die(the_repository->objects->sources);
|
git_test_write_commit_graph_or_die(the_repository->objects->sources);
|
||||||
|
|
||||||
repo_rerere(the_repository, 0);
|
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),
|
run_commit_hook(use_editor, repo_get_index_file(the_repository),
|
||||||
NULL, "post-commit", NULL);
|
NULL, "post-commit", NULL);
|
||||||
if (amend && !no_post_rewrite) {
|
if (amend && !no_post_rewrite) {
|
||||||
|
|
|
||||||
|
|
@ -2873,7 +2873,7 @@ int cmd_fetch(int argc,
|
||||||
if (opt_val != 0)
|
if (opt_val != 0)
|
||||||
git_config_push_parameter("maintenance.incremental-repack.auto=-1");
|
git_config_push_parameter("maintenance.incremental-repack.auto=-1");
|
||||||
}
|
}
|
||||||
run_auto_maintenance(verbosity < 0);
|
run_auto_maintenance(the_repository, verbosity < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
|
||||||
14
builtin/gc.c
14
builtin/gc.c
|
|
@ -1030,7 +1030,7 @@ int cmd_gc(int argc,
|
||||||
struct child_process repack_cmd = CHILD_PROCESS_INIT;
|
struct child_process repack_cmd = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
repack_cmd.git_cmd = 1;
|
repack_cmd.git_cmd = 1;
|
||||||
repack_cmd.close_object_store = 1;
|
repack_cmd.odb_to_close = the_repository->objects;
|
||||||
strvec_pushv(&repack_cmd.args, repack_args.v);
|
strvec_pushv(&repack_cmd.args, repack_args.v);
|
||||||
if (run_command(&repack_cmd))
|
if (run_command(&repack_cmd))
|
||||||
die(FAILED_RUN, repack_args.v[0]);
|
die(FAILED_RUN, repack_args.v[0]);
|
||||||
|
|
@ -1199,7 +1199,8 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts)
|
||||||
{
|
{
|
||||||
struct child_process child = CHILD_PROCESS_INIT;
|
struct child_process child = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
child.git_cmd = child.close_object_store = 1;
|
child.git_cmd = 1;
|
||||||
|
child.odb_to_close = the_repository->objects;
|
||||||
strvec_pushl(&child.args, "commit-graph", "write",
|
strvec_pushl(&child.args, "commit-graph", "write",
|
||||||
"--split", "--reachable", NULL);
|
"--split", "--reachable", NULL);
|
||||||
|
|
||||||
|
|
@ -1268,7 +1269,8 @@ static int maintenance_task_gc_background(struct maintenance_run_opts *opts,
|
||||||
{
|
{
|
||||||
struct child_process child = CHILD_PROCESS_INIT;
|
struct child_process child = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
child.git_cmd = child.close_object_store = 1;
|
child.git_cmd = 1;
|
||||||
|
child.odb_to_close = the_repository->objects;
|
||||||
strvec_push(&child.args, "gc");
|
strvec_push(&child.args, "gc");
|
||||||
|
|
||||||
if (opts->auto_flag)
|
if (opts->auto_flag)
|
||||||
|
|
@ -1484,7 +1486,8 @@ static int multi_pack_index_expire(struct maintenance_run_opts *opts)
|
||||||
{
|
{
|
||||||
struct child_process child = CHILD_PROCESS_INIT;
|
struct child_process child = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
child.git_cmd = child.close_object_store = 1;
|
child.git_cmd = 1;
|
||||||
|
child.odb_to_close = the_repository->objects;
|
||||||
strvec_pushl(&child.args, "multi-pack-index", "expire", NULL);
|
strvec_pushl(&child.args, "multi-pack-index", "expire", NULL);
|
||||||
|
|
||||||
if (opts->quiet)
|
if (opts->quiet)
|
||||||
|
|
@ -1542,7 +1545,8 @@ static int multi_pack_index_repack(struct maintenance_run_opts *opts)
|
||||||
{
|
{
|
||||||
struct child_process child = CHILD_PROCESS_INIT;
|
struct child_process child = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
child.git_cmd = child.close_object_store = 1;
|
child.git_cmd = 1;
|
||||||
|
child.odb_to_close = the_repository->objects;
|
||||||
strvec_pushl(&child.args, "multi-pack-index", "repack", NULL);
|
strvec_pushl(&child.args, "multi-pack-index", "repack", NULL);
|
||||||
|
|
||||||
if (opts->quiet)
|
if (opts->quiet)
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ static void finish(struct commit *head_commit,
|
||||||
* We ignore errors in 'gc --auto', since the
|
* We ignore errors in 'gc --auto', since the
|
||||||
* user should see them.
|
* user should see them.
|
||||||
*/
|
*/
|
||||||
run_auto_maintenance(verbosity < 0);
|
run_auto_maintenance(the_repository, verbosity < 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new_head && show_diffstat) {
|
if (new_head && show_diffstat) {
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ static int run_fetch(const char *repo, const char **refspecs)
|
||||||
} else if (*refspecs)
|
} else if (*refspecs)
|
||||||
BUG("refspecs without repo?");
|
BUG("refspecs without repo?");
|
||||||
cmd.git_cmd = 1;
|
cmd.git_cmd = 1;
|
||||||
cmd.close_object_store = 1;
|
cmd.odb_to_close = the_repository->objects;
|
||||||
return run_command(&cmd);
|
return run_command(&cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -562,7 +562,9 @@ static int finish_rebase(struct rebase_options *opts)
|
||||||
* We ignore errors in 'git maintenance run --auto', since the
|
* We ignore errors in 'git maintenance run --auto', since the
|
||||||
* user should see them.
|
* 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) {
|
if (opts->type == REBASE_MERGE) {
|
||||||
struct replay_opts replay = REPLAY_OPTS_INIT;
|
struct replay_opts replay = REPLAY_OPTS_INIT;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2727,7 +2727,7 @@ int cmd_receive_pack(int argc,
|
||||||
if (auto_gc) {
|
if (auto_gc) {
|
||||||
struct child_process proc = CHILD_PROCESS_INIT;
|
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.no_stdin = 1;
|
||||||
proc.stdout_to_stderr = 1;
|
proc.stdout_to_stderr = 1;
|
||||||
proc.err = use_sideband ? -1 : 0;
|
proc.err = use_sideband ? -1 : 0;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
#define USE_THE_REPOSITORY_VARIABLE
|
|
||||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
#define DISABLE_SIGN_COMPARE_WARNINGS
|
||||||
|
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
|
|
@ -742,8 +741,8 @@ fail_pipe:
|
||||||
|
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
|
|
||||||
if (cmd->close_object_store)
|
if (cmd->odb_to_close)
|
||||||
odb_close(the_repository->objects);
|
odb_close(cmd->odb_to_close);
|
||||||
|
|
||||||
#ifndef GIT_WINDOWS_NATIVE
|
#ifndef GIT_WINDOWS_NATIVE
|
||||||
{
|
{
|
||||||
|
|
@ -1937,11 +1936,12 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
|
||||||
trace2_region_leave(tr2_category, tr2_label, NULL);
|
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;
|
int enabled, auto_detach;
|
||||||
|
|
||||||
if (!repo_config_get_bool(the_repository, "maintenance.auto", &enabled) &&
|
if (!repo_config_get_bool(r, "maintenance.auto", &enabled) &&
|
||||||
!enabled)
|
!enabled)
|
||||||
return 0;
|
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
|
* honoring `gc.autoDetach`. This is somewhat weird, but required to
|
||||||
* retain behaviour from when we used to run git-gc(1) here.
|
* retain behaviour from when we used to run git-gc(1) here.
|
||||||
*/
|
*/
|
||||||
if (repo_config_get_bool(the_repository, "maintenance.autodetach", &auto_detach) &&
|
if (repo_config_get_bool(r, "maintenance.autodetach", &auto_detach) &&
|
||||||
repo_config_get_bool(the_repository, "gc.autodetach", &auto_detach))
|
repo_config_get_bool(r, "gc.autodetach", &auto_detach))
|
||||||
auto_detach = git_env_bool("GIT_TEST_MAINT_AUTO_DETACH", true);
|
auto_detach = git_env_bool("GIT_TEST_MAINT_AUTO_DETACH", true);
|
||||||
|
|
||||||
maint->git_cmd = 1;
|
maint->git_cmd = 1;
|
||||||
maint->close_object_store = 1;
|
maint->odb_to_close = r->objects;
|
||||||
strvec_pushl(&maint->args, "maintenance", "run", "--auto", NULL);
|
strvec_pushl(&maint->args, "maintenance", "run", "--auto", NULL);
|
||||||
strvec_push(&maint->args, quiet ? "--quiet" : "--no-quiet");
|
strvec_push(&maint->args, quiet ? "--quiet" : "--no-quiet");
|
||||||
strvec_push(&maint->args, auto_detach ? "--detach" : "--no-detach");
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_auto_maintenance(int quiet)
|
int run_auto_maintenance(struct repository *r, int quiet)
|
||||||
{
|
{
|
||||||
struct child_process maint = CHILD_PROCESS_INIT;
|
struct child_process maint = CHILD_PROCESS_INIT;
|
||||||
if (!prepare_auto_maintenance(quiet, &maint))
|
if (!prepare_auto_maintenance(r, quiet, &maint))
|
||||||
return 0;
|
return 0;
|
||||||
return run_command(&maint);
|
return run_command(&maint);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "strvec.h"
|
#include "strvec.h"
|
||||||
|
|
||||||
|
struct repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The run-command API offers a versatile tool to run sub-processes with
|
* The run-command API offers a versatile tool to run sub-processes with
|
||||||
* redirected input and output as well as with a modified environment
|
* redirected input and output as well as with a modified environment
|
||||||
|
|
@ -136,7 +138,7 @@ struct child_process {
|
||||||
* want to repack because that would delete `.pack` files (and on
|
* want to repack because that would delete `.pack` files (and on
|
||||||
* Windows, you cannot delete files that are still in use).
|
* Windows, you cannot delete files that are still in use).
|
||||||
*/
|
*/
|
||||||
unsigned close_object_store:1;
|
struct object_database *odb_to_close;
|
||||||
|
|
||||||
unsigned stdout_to_stderr:1;
|
unsigned stdout_to_stderr:1;
|
||||||
unsigned clean_on_exit:1;
|
unsigned clean_on_exit:1;
|
||||||
|
|
@ -227,12 +229,13 @@ int run_command(struct child_process *);
|
||||||
* process has been prepared and is ready to run, or 0 in case auto-maintenance
|
* process has been prepared and is ready to run, or 0 in case auto-maintenance
|
||||||
* should be skipped.
|
* should be skipped.
|
||||||
*/
|
*/
|
||||||
int prepare_auto_maintenance(int quiet, struct child_process *maint);
|
int prepare_auto_maintenance(struct repository *r, int quiet,
|
||||||
|
struct child_process *maint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trigger an auto-gc
|
* Trigger an auto-gc
|
||||||
*/
|
*/
|
||||||
int run_auto_maintenance(int quiet);
|
int run_auto_maintenance(struct repository *r, int quiet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the given command, sending "in" to its stdin, and capturing its
|
* Execute the given command, sending "in" to its stdin, and capturing its
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue