From: Junio C Hamano <gitster@pobox.com>
To: Pierrick Gaudry <pierrick.gaudry@loria.fr>
Cc: git@vger.kernel.org
Subject: Re: option -q not passed from "git commit" to "git gc --auto"
Date: Wed, 06 May 2020 10:31:31 -0700 [thread overview]
Message-ID: <xmqqd07h6kcs.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200506094327.GC31637@rillettes> (Pierrick Gaudry's message of "Wed, 6 May 2020 11:43:27 +0200")
Pierrick Gaudry <pierrick.gaudry@loria.fr> writes:
> Hello,
>
> It seems that when "git commit" is run with the "-q" option, there are
> still, from time to time, messages that get printed. With the French
> locale the message is:
> Compression automatique du dépôt en tâche de fond pour optimiser les performances.
> Voir "git help gc" pour toute information sur le nettoyage manuel.
>
> From what I could guess, this is due to the fact that "git commit" calls
> "git gc --auto", but does not propagate the "-q" option if present.
>
> A similar problem was present some time ago with "git fetch" and was
> solved in the 2-line patch 6fceed3b . I guess that the same should be
> done for "git commit".
Hmph, once our minds are on this, we probably should see how
widespread the issues would be before just "fixing" commit.
$ git grep -e 'gc.*,.*--auto' \*.c
builtin/am.c: const char *argv_gc_auto[] = {"gc", "--auto", NULL};
builtin/commit.c: const char *argv_gc_auto[] = {"gc", "--auto", NULL};
builtin/fetch.c: argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
builtin/merge.c: const char *argv_gc_auto[] = { "gc", "--auto", NULL };
builtin/rebase.c: const char *argv_gc_auto[] = { "gc", "--auto", NULL };
builtin/receive-pack.c: "gc", "--auto", "--quiet", NULL,
It is quite clear that "git am --quiet" will ignore "--quiet" (there
is no room to pass an extra argument to "gc --auto"). "merge" and
"rebase" are in the same boat.
I'd rather not see a fix that mimicks 6fceed3b (fetch: silence
git-gc if --quiet is given, 2014-08-16). Instead why not introduce
a helper "int run_auto_gc(int quiet)" and use it consistently when
we run the auto-gc?
An illustration to cover these (not even compile tested) to show
what I mean and help anybody get started.
builtin/am.c | 3 +--
builtin/commit.c | 3 +--
builtin/merge.c | 3 +--
builtin/rebase.c | 3 +--
4 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/builtin/am.c b/builtin/am.c
index e3dfd93c25..955f91f076 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -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 @@ static void am_run(struct am_state *state, int resume)
if (!state->rebasing) {
am_destroy(state);
close_object_store(the_repository->objects);
- run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+ run_gc_auto(state->quiet);
}
}
diff --git a/builtin/commit.c b/builtin/commit.c
index a73de0a4c5..15755a52e1 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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_gc_auto(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);
diff --git a/builtin/merge.c b/builtin/merge.c
index 923e32acf1..2361e3604a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -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_gc_auto(verbosity < 0);
}
}
if (new_head && show_diffstat) {
diff --git a/builtin/rebase.c b/builtin/rebase.c
index fb1227de45..2edd2ea596 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -737,7 +737,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);
@@ -747,7 +746,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;
next prev parent reply other threads:[~2020-05-06 17:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 9:43 option -q not passed from "git commit" to "git gc --auto" Pierrick Gaudry
2020-05-06 17:28 ` Taylor Blau
2020-05-06 17:33 ` Taylor Blau
2020-05-06 17:38 ` Taylor Blau
2020-05-06 17:31 ` Junio C Hamano [this message]
2020-05-06 18:56 ` Re* " Junio C Hamano
2020-05-06 19:03 ` [PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase Junio C Hamano
2020-05-06 19:27 ` Junio C Hamano
2020-05-06 20:18 ` [PATCH 0/2] Pass down "--quiet" to "gc --auto" Junio C Hamano
2020-05-06 20:18 ` [PATCH 1/2] auto-gc: extract a reusable helper from "git fetch" Junio C Hamano
2020-05-06 20:18 ` [PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase Junio C Hamano
2020-05-07 17:22 ` Taylor Blau
2020-05-07 19:31 ` 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=xmqqd07h6kcs.fsf@gitster.c.googlers.com \
--to=gitster@pobox.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).