git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] commit: silence git-gc if --quiet is given

From
Abhishek Kumar <abhishekkumar8222@gmail.com>
Date
May 6, 2020, 14:01 UTC
Message-ID
<20200506140138.650455-1-abhishekkumar8222@gmail.com>

As reported by Perrick [1], commit does not propagate quiet behavior to gc if present. While we are at it, convert argv_gc_auto to struct argv_array.

[1]: https://lore.kernel.org/git/20200506094327.GC31637@rillettes/
Reported-by: Pierrick Gaudry <pierrick.gaudry@loria.fr>
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
---
 builtin/commit.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index a73de0a4c5..a48e312ebd 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1494,7 +1494,7 @@ 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};
+	struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
 	static struct wt_status s;
 	static struct option builtin_commit_options[] = {
 		OPT__QUIET(&quiet, N_("suppress summary after successful commit")),
@@ -1703,7 +1703,11 @@ 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);
+	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+	if (quiet)
+		argv_array_push(&argv_gc_auto, "--quiet");
+	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+	argv_array_clear(&argv_gc_auto);
 	run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
 	if (amend && !no_post_rewrite) {
 		commit_post_rewrite(the_repository, current_head, &oid);
-- 
2.26.0
Next: Eric Sunshine
Message 1 of 3 in “commit: silence git-gc if --quiet is given”
  1. commit: silence git-gc if --quiet is givenAbhishek Kumar, May 6, 2020
  2. Eric SunshineMay 6, 2020
  3. Junio C HamanoMay 6, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.