mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
Merge branch 'jc/auto-gc-quiet'
Teach "am", "commit", "merge" and "rebase", when they are run with the "--quiet" option, to pass "--quiet" down to "gc --auto". * jc/auto-gc-quiet: auto-gc: pass --quiet down from am, commit, merge and rebase auto-gc: extract a reusable helper from "git fetch"
This commit is contained in:
commit
3af459e48d
@ -1691,7 +1691,6 @@ static int do_interactive(struct am_state *state)
|
||||
*/
|
||||
static void am_run(struct am_state *state, int resume)
|
||||
{
|
||||
const char *argv_gc_auto[] = {"gc", "--auto", NULL};
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
unlink(am_path(state, "dirtyindex"));
|
||||
@ -1796,7 +1795,7 @@ next:
|
||||
if (!state->rebasing) {
|
||||
am_destroy(state);
|
||||
close_object_store(the_repository->objects);
|
||||
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
|
||||
run_auto_gc(state->quiet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1494,7 +1494,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)
|
||||
|
||||
int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
const char *argv_gc_auto[] = {"gc", "--auto", NULL};
|
||||
static struct wt_status s;
|
||||
static struct option builtin_commit_options[] = {
|
||||
OPT__QUIET(&quiet, N_("suppress summary after successful commit")),
|
||||
@ -1703,7 +1702,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||
git_test_write_commit_graph_or_die();
|
||||
|
||||
repo_rerere(the_repository, 0);
|
||||
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
|
||||
run_auto_gc(quiet);
|
||||
run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
|
||||
if (amend && !no_post_rewrite) {
|
||||
commit_post_rewrite(the_repository, current_head, &oid);
|
||||
|
@ -1753,7 +1753,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
|
||||
struct remote *remote = NULL;
|
||||
int result = 0;
|
||||
int prune_tags_ok = 1;
|
||||
struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
|
||||
|
||||
packet_trace_identity("fetch");
|
||||
|
||||
@ -1880,13 +1879,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
|
||||
|
||||
close_object_store(the_repository->objects);
|
||||
|
||||
if (enable_auto_gc) {
|
||||
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
|
||||
if (verbosity < 0)
|
||||
argv_array_push(&argv_gc_auto, "--quiet");
|
||||
run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
|
||||
argv_array_clear(&argv_gc_auto);
|
||||
}
|
||||
if (enable_auto_gc)
|
||||
run_auto_gc(verbosity < 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -450,7 +450,6 @@ static void finish(struct commit *head_commit,
|
||||
if (verbosity >= 0 && !merge_msg.len)
|
||||
printf(_("No merge message -- not updating HEAD\n"));
|
||||
else {
|
||||
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
|
||||
update_ref(reflog_message.buf, "HEAD", new_head, head,
|
||||
0, UPDATE_REFS_DIE_ON_ERR);
|
||||
/*
|
||||
@ -458,7 +457,7 @@ static void finish(struct commit *head_commit,
|
||||
* user should see them.
|
||||
*/
|
||||
close_object_store(the_repository->objects);
|
||||
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
|
||||
run_auto_gc(verbosity < 0);
|
||||
}
|
||||
}
|
||||
if (new_head && show_diffstat) {
|
||||
|
@ -722,7 +722,6 @@ static int rebase_write_basic_state(struct rebase_options *opts)
|
||||
static int finish_rebase(struct rebase_options *opts)
|
||||
{
|
||||
struct strbuf dir = STRBUF_INIT;
|
||||
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
|
||||
int ret = 0;
|
||||
|
||||
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
|
||||
@ -732,7 +731,7 @@ static int finish_rebase(struct rebase_options *opts)
|
||||
* We ignore errors in 'gc --auto', since the
|
||||
* user should see them.
|
||||
*/
|
||||
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
|
||||
run_auto_gc(!(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE)));
|
||||
if (opts->type == REBASE_MERGE) {
|
||||
struct replay_opts replay = REPLAY_OPTS_INIT;
|
||||
|
||||
|
@ -1864,3 +1864,16 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int run_auto_gc(int quiet)
|
||||
{
|
||||
struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
|
||||
int status;
|
||||
|
||||
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
|
||||
if (quiet)
|
||||
argv_array_push(&argv_gc_auto, "--quiet");
|
||||
status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
|
||||
argv_array_clear(&argv_gc_auto);
|
||||
return status;
|
||||
}
|
||||
|
@ -218,6 +218,11 @@ LAST_ARG_MUST_BE_NULL
|
||||
int run_hook_le(const char *const *env, const char *name, ...);
|
||||
int run_hook_ve(const char *const *env, const char *name, va_list args);
|
||||
|
||||
/*
|
||||
* Trigger an auto-gc
|
||||
*/
|
||||
int run_auto_gc(int quiet);
|
||||
|
||||
#define RUN_COMMAND_NO_STDIN 1
|
||||
#define RUN_GIT_CMD 2 /*If this is to be git sub-command */
|
||||
#define RUN_COMMAND_STDOUT_TO_STDERR 4
|
||||
|
Loading…
Reference in New Issue
Block a user