summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-05-06 20:18:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-07 19:24:33 (GMT)
commit850b6edefa7a4fcc75149447cb8a984f804dd080 (patch)
tree247e4bb6b77b2517b67b771736a13303de3ef1a9 /run-command.c
parentaf6b65d45ef179ed52087e80cb089f6b2349f4ec (diff)
downloadgit-850b6edefa7a4fcc75149447cb8a984f804dd080.zip
git-850b6edefa7a4fcc75149447cb8a984f804dd080.tar.gz
git-850b6edefa7a4fcc75149447cb8a984f804dd080.tar.bz2
auto-gc: extract a reusable helper from "git fetch"
Back in 1991006c (fetch: convert argv_gc_auto to struct argv_array, 2014-08-16), we taught "git fetch --quiet" to pass the "--quiet" option down to "gc --auto". This issue, however, is not limited to "fetch": $ git grep -e 'gc.*--auto' \*.c finds hits in "am", "commit", "merge", and "rebase" and these commands do not pass "--quiet" down to "gc --auto" when they themselves are told to be quiet. As a preparatory step, let's introduce a helper function run_auto_gc(), that the caller can pass a boolean "quiet", and redo the fix to "git fetch" using the helper. Signed-off-by: Junio C Hamano <gitster@pobox.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c
index f5e1149..2771eb9 100644
--- a/run-command.c
+++ b/run-command.c
@@ -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;
+}