git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abhishek Kumar <abhishekkumar8222@gmail.com>
To: git@vger.kernel.org
Cc: Pierrick Gaudry <pierrick.gaudry@loria.fr>
Subject: [PATCH] commit: silence git-gc if --quiet is given
Date: Wed,  6 May 2020 19:31:38 +0530	[thread overview]
Message-ID: <20200506140138.650455-1-abhishekkumar8222@gmail.com> (raw)

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


             reply	other threads:[~2020-05-06 14:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 14:01 Abhishek Kumar [this message]
2020-05-06 16:09 ` [PATCH] commit: silence git-gc if --quiet is given Eric Sunshine
2020-05-06 17:33   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200506140138.650455-1-abhishekkumar8222@gmail.com \
    --to=abhishekkumar8222@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pierrick.gaudry@loria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).