{"thread":{"id":"53410","subject":"option -q not passed from \"git commit\" to \"git gc --auto\"","startedAt":"2020-05-06T09:43:31Z","lastAt":"2020-05-07T19:31:25Z","messageCount":13,"participants":["Pierrick Gaudry","Taylor Blau","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"397179","messageId":"20200506094327.GC31637@rillettes","threadId":"53410","inReplyTo":null,"subject":"option -q not passed from \"git commit\" to \"git gc --auto\"","fromName":"Pierrick Gaudry","fromEmail":"pierrick.gaudry@loria.fr","sentAt":"2020-05-06T09:43:27Z","receivedAt":"2020-05-06T09:43:31Z","isPatch":false,"sender":{"key":"pierrick.gaudry@loria.fr","avatar":null},"body":"Hello,\n\nIt seems that when \"git commit\" is run with the \"-q\" option, there are\nstill, from time to time, messages that get printed. With the French\nlocale the message is:\n  Compression automatique du dépôt en tâche de fond pour optimiser les performances.\n  Voir \"git help gc\" pour toute information sur le nettoyage manuel.\n\nFrom what I could guess, this is due to the fact that \"git commit\" calls\n\"git gc --auto\", but does not propagate the \"-q\" option if present.\n\nA similar problem was present some time ago with \"git fetch\" and was\nsolved in the 2-line patch 6fceed3b . I guess that the same should be\ndone for \"git commit\".\n\nRegards,\nPierrick\n"},{"id":"397215","messageId":"20200506172823.GB6078@syl.local","threadId":"53410","inReplyTo":"20200506094327.GC31637@rillettes","subject":"Re: option -q not passed from \"git commit\" to \"git gc --auto\"","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-05-06T17:28:23Z","receivedAt":"2020-05-06T17:28:31Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, May 06, 2020 at 11:43:27AM +0200, Pierrick Gaudry wrote:\n> Hello,\n>\n> It seems that when \"git commit\" is run with the \"-q\" option, there are\n> still, from time to time, messages that get printed. With the French\n> locale the message is:\n>   Compression automatique du dépôt en tâche de fond pour optimiser les performances.\n>   Voir \"git help gc\" pour toute information sur le nettoyage manuel.\n>\n> From what I could guess, this is due to the fact that \"git commit\" calls\n> \"git gc --auto\", but does not propagate the \"-q\" option if present.\n>\n> A similar problem was present some time ago with \"git fetch\" and was\n> solved in the 2-line patch 6fceed3b . I guess that the same should be\n> done for \"git commit\".\n\nYes, I think so. A quick search through the list archive turns up [1],\nwhich identifies and provides a patch for this issue. If I were\nreviewing that patch today, I'd suggest the following:\n\n  * break the change from a 'char **' to a 'struct argv_array' into a\n    separate, preparatory patch.\n\n  * adjust the commit message of the second commit (which will only pass\n    '-q' to the 'git-gc' sub-process) to indicate that there may be\n    other locations\n\n  * fix those other locations that spawn 'git gc', if they exist, in a\n    similar fashion\n\n  * in each of the previous two steps, add tests in the appropriate\n    files in 't' to demonstrate that '-q' propagation works as expected.\n\nI'm happy to do any and all of this, if you want, but you are also\nwelcome to submit the patches yourself.\n\n> Regards,\n> Pierrick\n\nThanks,\nTaylor\n\n[1]: https://lore.kernel.org/git/20200506140138.650455-1-abhishekkumar8222@gmail.com/\n"},{"id":"397216","messageId":"xmqqd07h6kcs.fsf@gitster.c.googlers.com","threadId":"53410","inReplyTo":"20200506094327.GC31637@rillettes","subject":"Re: option -q not passed from \"git commit\" to \"git gc --auto\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T17:31:31Z","receivedAt":"2020-05-06T17:31:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierrick Gaudry <pierrick.gaudry@loria.fr> writes:\n\n> Hello,\n>\n> It seems that when \"git commit\" is run with the \"-q\" option, there are\n> still, from time to time, messages that get printed. With the French\n> locale the message is:\n>   Compression automatique du dépôt en tâche de fond pour optimiser les performances.\n>   Voir \"git help gc\" pour toute information sur le nettoyage manuel.\n>\n> From what I could guess, this is due to the fact that \"git commit\" calls\n> \"git gc --auto\", but does not propagate the \"-q\" option if present.\n>\n> A similar problem was present some time ago with \"git fetch\" and was\n> solved in the 2-line patch 6fceed3b . I guess that the same should be\n> done for \"git commit\".\n\nHmph, once our minds are on this, we probably should see how\nwidespread the issues would be before just \"fixing\" commit.\n\n$ git grep -e 'gc.*,.*--auto' \\*.c\nbuiltin/am.c:\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\nbuiltin/commit.c:\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\nbuiltin/fetch.c:\t\targv_array_pushl(&argv_gc_auto, \"gc\", \"--auto\", NULL);\nbuiltin/merge.c:\t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\nbuiltin/rebase.c:\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\nbuiltin/receive-pack.c:\t\t\t\t\"gc\", \"--auto\", \"--quiet\", NULL,\n\nIt is quite clear that \"git am --quiet\" will ignore \"--quiet\" (there\nis no room to pass an extra argument to \"gc --auto\").  \"merge\" and\n\"rebase\" are in the same boat.\n\nI'd rather not see a fix that mimicks 6fceed3b (fetch: silence\ngit-gc if --quiet is given, 2014-08-16).  Instead why not introduce\na helper \"int run_auto_gc(int quiet)\" and use it consistently when\nwe run the auto-gc?\n\nAn illustration to cover these (not even compile tested) to show\nwhat I mean and help anybody get started.\n\n builtin/am.c     | 3 +--\n builtin/commit.c | 3 +--\n builtin/merge.c  | 3 +--\n builtin/rebase.c | 3 +--\n 4 files changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex e3dfd93c25..955f91f076 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1691,7 +1691,6 @@ static int do_interactive(struct am_state *state)\n  */\n static void am_run(struct am_state *state, int resume)\n {\n-\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\n \tstruct strbuf sb = STRBUF_INIT;\n \n \tunlink(am_path(state, \"dirtyindex\"));\n@@ -1796,7 +1795,7 @@ static void am_run(struct am_state *state, int resume)\n \tif (!state->rebasing) {\n \t\tam_destroy(state);\n \t\tclose_object_store(the_repository->objects);\n-\t\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\t\trun_gc_auto(state->quiet);\n \t}\n }\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a73de0a4c5..15755a52e1 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1494,7 +1494,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)\n \n int cmd_commit(int argc, const char **argv, const char *prefix)\n {\n-\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\n \tstatic struct wt_status s;\n \tstatic struct option builtin_commit_options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"suppress summary after successful commit\")),\n@@ -1703,7 +1702,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tgit_test_write_commit_graph_or_die();\n \n \trepo_rerere(the_repository, 0);\n-\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\trun_gc_auto(quiet);\n \trun_commit_hook(use_editor, get_index_file(), \"post-commit\", NULL);\n \tif (amend && !no_post_rewrite) {\n \t\tcommit_post_rewrite(the_repository, current_head, &oid);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 923e32acf1..2361e3604a 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -450,7 +450,6 @@ static void finish(struct commit *head_commit,\n \t\tif (verbosity >= 0 && !merge_msg.len)\n \t\t\tprintf(_(\"No merge message -- not updating HEAD\\n\"));\n \t\telse {\n-\t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \t\t\tupdate_ref(reflog_message.buf, \"HEAD\", new_head, head,\n \t\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \t\t\t/*\n@@ -458,7 +457,7 @@ static void finish(struct commit *head_commit,\n \t\t\t * user should see them.\n \t\t\t */\n \t\t\tclose_object_store(the_repository->objects);\n-\t\t\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\t\t\trun_gc_auto(verbosity < 0);\n \t\t}\n \t}\n \tif (new_head && show_diffstat) {\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex fb1227de45..2edd2ea596 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -737,7 +737,6 @@ static int rebase_write_basic_state(struct rebase_options *opts)\n static int finish_rebase(struct rebase_options *opts)\n {\n \tstruct strbuf dir = STRBUF_INIT;\n-\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \tint ret = 0;\n \n \tdelete_ref(NULL, \"REBASE_HEAD\", NULL, REF_NO_DEREF);\n@@ -747,7 +746,7 @@ static int finish_rebase(struct rebase_options *opts)\n \t * We ignore errors in 'gc --auto', since the\n \t * user should see them.\n \t */\n-\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\trun_auto_gc(!(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE)));\n \tif (opts->type == REBASE_MERGE) {\n \t\tstruct replay_opts replay = REPLAY_OPTS_INIT;\n \n"},{"id":"397218","messageId":"20200506173356.GC6078@syl.local","threadId":"53410","inReplyTo":"20200506172823.GB6078@syl.local","subject":"Re: option -q not passed from \"git commit\" to \"git gc --auto\"","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-05-06T17:33:56Z","receivedAt":"2020-05-06T17:34:00Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, May 06, 2020 at 11:28:23AM -0600, Taylor Blau wrote:\n> On Wed, May 06, 2020 at 11:43:27AM +0200, Pierrick Gaudry wrote:\n> > Hello,\n> >\n> > It seems that when \"git commit\" is run with the \"-q\" option, there are\n> > still, from time to time, messages that get printed. With the French\n> > locale the message is:\n> >   Compression automatique du dépôt en tâche de fond pour optimiser les performances.\n> >   Voir \"git help gc\" pour toute information sur le nettoyage manuel.\n> >\n> > From what I could guess, this is due to the fact that \"git commit\" calls\n> > \"git gc --auto\", but does not propagate the \"-q\" option if present.\n> >\n> > A similar problem was present some time ago with \"git fetch\" and was\n> > solved in the 2-line patch 6fceed3b . I guess that the same should be\n> > done for \"git commit\".\n>\n> Yes, I think so. A quick search through the list archive turns up [1],\n> which identifies and provides a patch for this issue. If I were\n> reviewing that patch today, I'd suggest the following:\n>\n>   * break the change from a 'char **' to a 'struct argv_array' into a\n>     separate, preparatory patch.\n>\n>   * adjust the commit message of the second commit (which will only pass\n>     '-q' to the 'git-gc' sub-process) to indicate that there may be\n>     other locations\n>\n>   * fix those other locations that spawn 'git gc', if they exist, in a\n>     similar fashion\n>\n>   * in each of the previous two steps, add tests in the appropriate\n>     files in 't' to demonstrate that '-q' propagation works as expected.\n\nJunio identified a much better way to do this in the email below this\none. Since it appears that there are multiple places that ignore\n'--quiet' when running 'git gc' as a sub-process, a helper function is\ncertainly you want to be using.\n\n> I'm happy to do any and all of this, if you want, but you are also\n> welcome to submit the patches yourself.\n>\n> > Regards,\n> > Pierrick\n>\n> Thanks,\n> Taylor\n>\n> [1]: https://lore.kernel.org/git/20200506140138.650455-1-abhishekkumar8222@gmail.com/\nThanks,\nTaylor\n"},{"id":"397220","messageId":"20200506173839.GA6598@syl.local","threadId":"53410","inReplyTo":"20200506173356.GC6078@syl.local","subject":"Re: option -q not passed from \"git commit\" to \"git gc --auto\"","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-05-06T17:38:39Z","receivedAt":"2020-05-06T17:38:45Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, May 06, 2020 at 11:33:56AM -0600, Taylor Blau wrote:\n> On Wed, May 06, 2020 at 11:28:23AM -0600, Taylor Blau wrote:\n> > On Wed, May 06, 2020 at 11:43:27AM +0200, Pierrick Gaudry wrote:\n> > > Hello,\n> > >\n> > > It seems that when \"git commit\" is run with the \"-q\" option, there are\n> > > still, from time to time, messages that get printed. With the French\n> > > locale the message is:\n> > >   Compression automatique du dépôt en tâche de fond pour optimiser les performances.\n> > >   Voir \"git help gc\" pour toute information sur le nettoyage manuel.\n> > >\n> > > From what I could guess, this is due to the fact that \"git commit\" calls\n> > > \"git gc --auto\", but does not propagate the \"-q\" option if present.\n> > >\n> > > A similar problem was present some time ago with \"git fetch\" and was\n> > > solved in the 2-line patch 6fceed3b . I guess that the same should be\n> > > done for \"git commit\".\n> >\n> > Yes, I think so. A quick search through the list archive turns up [1],\n> > which identifies and provides a patch for this issue. If I were\n> > reviewing that patch today, I'd suggest the following:\n\nOh, [1] is an email from today. Clearly I am not finished reading my\ninbox yet. Sorry about that.\n\n> >   * break the change from a 'char **' to a 'struct argv_array' into a\n> >     separate, preparatory patch.\n> >\n> >   * adjust the commit message of the second commit (which will only pass\n> >     '-q' to the 'git-gc' sub-process) to indicate that there may be\n> >     other locations\n> >\n> >   * fix those other locations that spawn 'git gc', if they exist, in a\n> >     similar fashion\n> >\n> >   * in each of the previous two steps, add tests in the appropriate\n> >     files in 't' to demonstrate that '-q' propagation works as expected.\n>\n> Junio identified a much better way to do this in the email below this\n> one. Since it appears that there are multiple places that ignore\n> '--quiet' when running 'git gc' as a sub-process, a helper function is\n> certainly you want to be using.\n>\n> > I'm happy to do any and all of this, if you want, but you are also\n> > welcome to submit the patches yourself.\n> >\n> > > Regards,\n> > > Pierrick\n> >\n> > Thanks,\n> > Taylor\n> >\n> > [1]: https://lore.kernel.org/git/20200506140138.650455-1-abhishekkumar8222@gmail.com/\n> Thanks,\n> Taylor\nThanks,\nTaylor\n"},{"id":"397228","messageId":"xmqqpnbg6gfv.fsf_-_@gitster.c.googlers.com","threadId":"53410","inReplyTo":"xmqqd07h6kcs.fsf@gitster.c.googlers.com","subject":"Re* option -q not passed from \"git commit\" to \"git gc --auto\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T18:56:04Z","receivedAt":"2020-05-06T18:56:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> An illustration to cover these (not even compile tested) to show\n> what I mean and help anybody get started.\n\n\nAnd this would be a good first step in the conversion.\n\n-- >8 --\nSubject: [PATCH] run_auto_gc(): extract a reusable helper\n\nEarlier we taught \"git fetch --quiet\" to pass the \"--quiet\" option\ndown to \"gc --auto\".  This, however, is not limited to \"fetch\":\n\n    $ git grep -e 'gc.*--auto' \\*.c\n\nfinds hits in \"am\", \"commit\", \"merge\", and \"rebase\".\n\nAs a preparatory step, let's introduce a helper function\nrun_auto_gc(), that the caller can pass a boolean \"quiet\".\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/fetch.c | 10 ++--------\n run-command.c   | 13 +++++++++++++\n run-command.h   |  5 +++++\n 3 files changed, 20 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex bf6bab80fa..3e580b9559 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1759,7 +1759,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \tstruct remote *remote = NULL;\n \tint result = 0;\n \tint prune_tags_ok = 1;\n-\tstruct argv_array argv_gc_auto = ARGV_ARRAY_INIT;\n \n \tpacket_trace_identity(\"fetch\");\n \n@@ -1886,13 +1885,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \n \tclose_object_store(the_repository->objects);\n \n-\tif (enable_auto_gc) {\n-\t\targv_array_pushl(&argv_gc_auto, \"gc\", \"--auto\", NULL);\n-\t\tif (verbosity < 0)\n-\t\t\targv_array_push(&argv_gc_auto, \"--quiet\");\n-\t\trun_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);\n-\t\targv_array_clear(&argv_gc_auto);\n-\t}\n+\tif (enable_auto_gc)\n+\t\trun_auto_gc(verbosity < 0);\n \n \treturn result;\n }\ndiff --git a/run-command.c b/run-command.c\nindex f5e1149f9b..2771eb936f 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1864,3 +1864,16 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,\n \n \treturn result;\n }\n+\n+int run_auto_gc(int quiet)\n+{\n+\tstruct argv_array argv_gc_auto = ARGV_ARRAY_INIT;\n+\tint status;\n+\n+\targv_array_pushl(&argv_gc_auto, \"gc\", \"--auto\", NULL);\n+\tif (quiet)\n+\t\targv_array_push(&argv_gc_auto, \"--quiet\");\n+\tstatus = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);\n+\targv_array_clear(&argv_gc_auto);\n+\treturn status;\n+}\ndiff --git a/run-command.h b/run-command.h\nindex 0f3cc73ab6..191dfcdafe 100644\n--- a/run-command.h\n+++ b/run-command.h\n@@ -218,6 +218,11 @@ LAST_ARG_MUST_BE_NULL\n int run_hook_le(const char *const *env, const char *name, ...);\n int run_hook_ve(const char *const *env, const char *name, va_list args);\n \n+/*\n+ * Trigger an auto-gc\n+ */\n+int run_auto_gc(int quiet);\n+\n #define RUN_COMMAND_NO_STDIN 1\n #define RUN_GIT_CMD\t     2\t/*If this is to be git sub-command */\n #define RUN_COMMAND_STDOUT_TO_STDERR 4\n"},{"id":"397229","messageId":"xmqqlfm46g3x.fsf_-_@gitster.c.googlers.com","threadId":"53410","inReplyTo":"xmqqpnbg6gfv.fsf_-_@gitster.c.googlers.com","subject":"[PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T19:03:14Z","receivedAt":"2020-05-06T19:03:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"A handful of commands take the --quiet option for their own\noperation, but they forget to pass the option down when they\ninvoke \"git gc --auto\" internally.\n\nTeach these commands to do so using the run_gc_auto() helper we\nadded earlier.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n * And this is the earlier one, wrapped in a proper patch submission\n   format, to conclude the two-patch series.\n\n builtin/am.c     | 3 +--\n builtin/commit.c | 3 +--\n builtin/merge.c  | 3 +--\n builtin/rebase.c | 3 +--\n 4 files changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex e3dfd93c25..955f91f076 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1691,7 +1691,6 @@ static int do_interactive(struct am_state *state)\n  */\n static void am_run(struct am_state *state, int resume)\n {\n-\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\n \tstruct strbuf sb = STRBUF_INIT;\n \n \tunlink(am_path(state, \"dirtyindex\"));\n@@ -1796,7 +1795,7 @@ static void am_run(struct am_state *state, int resume)\n \tif (!state->rebasing) {\n \t\tam_destroy(state);\n \t\tclose_object_store(the_repository->objects);\n-\t\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\t\trun_gc_auto(state->quiet);\n \t}\n }\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 7ba33a3bec..b08c51ae49 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1488,7 +1488,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)\n \n int cmd_commit(int argc, const char **argv, const char *prefix)\n {\n-\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\n \tstatic struct wt_status s;\n \tstatic struct option builtin_commit_options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"suppress summary after successful commit\")),\n@@ -1697,7 +1696,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\treturn 1;\n \n \trepo_rerere(the_repository, 0);\n-\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\trun_gc_auto(quiet);\n \trun_commit_hook(use_editor, get_index_file(), \"post-commit\", NULL);\n \tif (amend && !no_post_rewrite) {\n \t\tcommit_post_rewrite(the_repository, current_head, &oid);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex d127d2225f..b6e9cebabf 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -447,7 +447,6 @@ static void finish(struct commit *head_commit,\n \t\tif (verbosity >= 0 && !merge_msg.len)\n \t\t\tprintf(_(\"No merge message -- not updating HEAD\\n\"));\n \t\telse {\n-\t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \t\t\tupdate_ref(reflog_message.buf, \"HEAD\", new_head, head,\n \t\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \t\t\t/*\n@@ -455,7 +454,7 @@ static void finish(struct commit *head_commit,\n \t\t\t * user should see them.\n \t\t\t */\n \t\t\tclose_object_store(the_repository->objects);\n-\t\t\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\t\t\trun_gc_auto(verbosity < 0);\n \t\t}\n \t}\n \tif (new_head && show_diffstat) {\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex bff53d5d16..fe1a9aba45 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -763,7 +763,6 @@ static int apply_autostash(struct rebase_options *opts)\n static int finish_rebase(struct rebase_options *opts)\n {\n \tstruct strbuf dir = STRBUF_INIT;\n-\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \tint ret = 0;\n \n \tdelete_ref(NULL, \"REBASE_HEAD\", NULL, REF_NO_DEREF);\n@@ -773,7 +772,7 @@ static int finish_rebase(struct rebase_options *opts)\n \t * We ignore errors in 'gc --auto', since the\n \t * user should see them.\n \t */\n-\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\trun_auto_gc(!(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE)));\n \tif (opts->type == REBASE_MERGE) {\n \t\tstruct replay_opts replay = REPLAY_OPTS_INIT;\n \n-- \n2.26.2-561-g07d8ea56f2\n\n"},{"id":"397231","messageId":"xmqqh7ws6ezl.fsf@gitster.c.googlers.com","threadId":"53410","inReplyTo":"xmqqlfm46g3x.fsf_-_@gitster.c.googlers.com","subject":"Re: [PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T19:27:26Z","receivedAt":"2020-05-06T19:27:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Teach these commands to do so using the run_gc_auto() helper we\n> added earlier.\n\nHeh, what was added was run_auto_gc(), so this patch would not work\nwell with the previous one.\n\nI'll send out a fixed one sometime later today.\n"},{"id":"397232","messageId":"20200506201830.92818-1-gitster@pobox.com","threadId":"53410","inReplyTo":"20200506094327.GC31637@rillettes","subject":"[PATCH 0/2] Pass down \"--quiet\" to \"gc --auto\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T20:18:28Z","receivedAt":"2020-05-06T20:18:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"A handful commands take \"--quiet\" from their command line,\nbut forgets to pass it down, when they trigger an auto gc,\nto the \"git gc --auto\" they internally invoke.\n\nBack in 1991006c (fetch: convert argv_gc_auto to struct argv_array,\n2014-08-16), we patched \"git fetch\" but seems to have forgotten\ndoing the same for \"git merge\".  Since then, rewrite of \"git am\" and\n\"git rebase\" in C spread the same problem into two more codepaths.\n\nLet's clean them up once and for all.\n\nJunio C Hamano (2):\n  run_auto_gc(): extract a reusable helper\n  auto-gc: pass --quiet down from am, commit, merge and rebase\n\n builtin/am.c     |  3 +--\n builtin/commit.c |  3 +--\n builtin/fetch.c  | 10 ++--------\n builtin/merge.c  |  3 +--\n builtin/rebase.c |  3 +--\n run-command.c    | 13 +++++++++++++\n run-command.h    |  5 +++++\n 7 files changed, 24 insertions(+), 16 deletions(-)\n\n-- \n2.26.2-561-g07d8ea56f2\n\n"},{"id":"397233","messageId":"20200506201830.92818-3-gitster@pobox.com","threadId":"53410","inReplyTo":"20200506201830.92818-1-gitster@pobox.com","subject":"[PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T20:18:30Z","receivedAt":"2020-05-06T20:18:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"These commands take the --quiet option for their own operation, but\nthey forget to pass the option down when they invoke \"git gc --auto\"\ninternally.\n\nTeach them to do so using the run_auto_gc() helper we added in the\nprevious step.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/am.c     | 3 +--\n builtin/commit.c | 3 +--\n builtin/merge.c  | 3 +--\n builtin/rebase.c | 3 +--\n 4 files changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex e3dfd93c25..69e50de018 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1691,7 +1691,6 @@ static int do_interactive(struct am_state *state)\n  */\n static void am_run(struct am_state *state, int resume)\n {\n-\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\n \tstruct strbuf sb = STRBUF_INIT;\n \n \tunlink(am_path(state, \"dirtyindex\"));\n@@ -1796,7 +1795,7 @@ static void am_run(struct am_state *state, int resume)\n \tif (!state->rebasing) {\n \t\tam_destroy(state);\n \t\tclose_object_store(the_repository->objects);\n-\t\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\t\trun_auto_gc(state->quiet);\n \t}\n }\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 7ba33a3bec..fa8eca623e 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1488,7 +1488,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)\n \n int cmd_commit(int argc, const char **argv, const char *prefix)\n {\n-\tconst char *argv_gc_auto[] = {\"gc\", \"--auto\", NULL};\n \tstatic struct wt_status s;\n \tstatic struct option builtin_commit_options[] = {\n \t\tOPT__QUIET(&quiet, N_(\"suppress summary after successful commit\")),\n@@ -1697,7 +1696,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\treturn 1;\n \n \trepo_rerere(the_repository, 0);\n-\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\trun_auto_gc(quiet);\n \trun_commit_hook(use_editor, get_index_file(), \"post-commit\", NULL);\n \tif (amend && !no_post_rewrite) {\n \t\tcommit_post_rewrite(the_repository, current_head, &oid);\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex d127d2225f..c66b9b532c 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -447,7 +447,6 @@ static void finish(struct commit *head_commit,\n \t\tif (verbosity >= 0 && !merge_msg.len)\n \t\t\tprintf(_(\"No merge message -- not updating HEAD\\n\"));\n \t\telse {\n-\t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \t\t\tupdate_ref(reflog_message.buf, \"HEAD\", new_head, head,\n \t\t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \t\t\t/*\n@@ -455,7 +454,7 @@ static void finish(struct commit *head_commit,\n \t\t\t * user should see them.\n \t\t\t */\n \t\t\tclose_object_store(the_repository->objects);\n-\t\t\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\t\t\trun_auto_gc(verbosity < 0);\n \t\t}\n \t}\n \tif (new_head && show_diffstat) {\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex bff53d5d16..fe1a9aba45 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -763,7 +763,6 @@ static int apply_autostash(struct rebase_options *opts)\n static int finish_rebase(struct rebase_options *opts)\n {\n \tstruct strbuf dir = STRBUF_INIT;\n-\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n \tint ret = 0;\n \n \tdelete_ref(NULL, \"REBASE_HEAD\", NULL, REF_NO_DEREF);\n@@ -773,7 +772,7 @@ static int finish_rebase(struct rebase_options *opts)\n \t * We ignore errors in 'gc --auto', since the\n \t * user should see them.\n \t */\n-\trun_command_v_opt(argv_gc_auto, RUN_GIT_CMD);\n+\trun_auto_gc(!(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE)));\n \tif (opts->type == REBASE_MERGE) {\n \t\tstruct replay_opts replay = REPLAY_OPTS_INIT;\n \n-- \n2.26.2-561-g07d8ea56f2\n\n"},{"id":"397234","messageId":"20200506201830.92818-2-gitster@pobox.com","threadId":"53410","inReplyTo":"20200506201830.92818-1-gitster@pobox.com","subject":"[PATCH 1/2] auto-gc: extract a reusable helper from \"git fetch\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-06T20:18:29Z","receivedAt":"2020-05-06T20:18:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Back in 1991006c (fetch: convert argv_gc_auto to struct argv_array,\n2014-08-16), we taught \"git fetch --quiet\" to pass the \"--quiet\"\noption down to \"gc --auto\".  This issue, however, is not limited to\n\"fetch\":\n\n    $ git grep -e 'gc.*--auto' \\*.c\n\nfinds hits in \"am\", \"commit\", \"merge\", and \"rebase\" and these\ncommands do not pass \"--quiet\" down to \"gc --auto\" when they\nthemselves are told to be quiet.\n\nAs a preparatory step, let's introduce a helper function\nrun_auto_gc(), that the caller can pass a boolean \"quiet\",\nand redo the fix to \"git fetch\" using the helper.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/fetch.c | 10 ++--------\n run-command.c   | 13 +++++++++++++\n run-command.h   |  5 +++++\n 3 files changed, 20 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex bf6bab80fa..3e580b9559 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1759,7 +1759,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \tstruct remote *remote = NULL;\n \tint result = 0;\n \tint prune_tags_ok = 1;\n-\tstruct argv_array argv_gc_auto = ARGV_ARRAY_INIT;\n \n \tpacket_trace_identity(\"fetch\");\n \n@@ -1886,13 +1885,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \n \tclose_object_store(the_repository->objects);\n \n-\tif (enable_auto_gc) {\n-\t\targv_array_pushl(&argv_gc_auto, \"gc\", \"--auto\", NULL);\n-\t\tif (verbosity < 0)\n-\t\t\targv_array_push(&argv_gc_auto, \"--quiet\");\n-\t\trun_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);\n-\t\targv_array_clear(&argv_gc_auto);\n-\t}\n+\tif (enable_auto_gc)\n+\t\trun_auto_gc(verbosity < 0);\n \n \treturn result;\n }\ndiff --git a/run-command.c b/run-command.c\nindex f5e1149f9b..2771eb936f 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1864,3 +1864,16 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,\n \n \treturn result;\n }\n+\n+int run_auto_gc(int quiet)\n+{\n+\tstruct argv_array argv_gc_auto = ARGV_ARRAY_INIT;\n+\tint status;\n+\n+\targv_array_pushl(&argv_gc_auto, \"gc\", \"--auto\", NULL);\n+\tif (quiet)\n+\t\targv_array_push(&argv_gc_auto, \"--quiet\");\n+\tstatus = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);\n+\targv_array_clear(&argv_gc_auto);\n+\treturn status;\n+}\ndiff --git a/run-command.h b/run-command.h\nindex 0f3cc73ab6..191dfcdafe 100644\n--- a/run-command.h\n+++ b/run-command.h\n@@ -218,6 +218,11 @@ LAST_ARG_MUST_BE_NULL\n int run_hook_le(const char *const *env, const char *name, ...);\n int run_hook_ve(const char *const *env, const char *name, va_list args);\n \n+/*\n+ * Trigger an auto-gc\n+ */\n+int run_auto_gc(int quiet);\n+\n #define RUN_COMMAND_NO_STDIN 1\n #define RUN_GIT_CMD\t     2\t/*If this is to be git sub-command */\n #define RUN_COMMAND_STDOUT_TO_STDERR 4\n-- \n2.26.2-561-g07d8ea56f2\n\n"},{"id":"397326","messageId":"20200507172201.GD26677@syl.local","threadId":"53410","inReplyTo":"20200506201830.92818-3-gitster@pobox.com","subject":"Re: [PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-05-07T17:22:01Z","receivedAt":"2020-05-07T17:22:06Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi Junio,\n\nOn Wed, May 06, 2020 at 01:18:30PM -0700, Junio C Hamano wrote:\n> These commands take the --quiet option for their own operation, but\n> they forget to pass the option down when they invoke \"git gc --auto\"\n> internally.\n>\n> Teach them to do so using the run_auto_gc() helper we added in the\n> previous step.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  builtin/am.c     | 3 +--\n>  builtin/commit.c | 3 +--\n>  builtin/merge.c  | 3 +--\n>  builtin/rebase.c | 3 +--\n>  4 files changed, 4 insertions(+), 8 deletions(-)\n\nVery nicely done. Sorry that these took me a little while to look at.\nThis and the patch before it both have my:\n\n  Reviewed-by: Taylor Blau <me@ttaylorr.com>\n\nThanks,\nTaylor\n"},{"id":"397337","messageId":"xmqq5zd74k56.fsf@gitster.c.googlers.com","threadId":"53410","inReplyTo":"20200507172201.GD26677@syl.local","subject":"Re: [PATCH 2/2] auto-gc: pass --quiet down from am, commit, merge and rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-05-07T19:31:17Z","receivedAt":"2020-05-07T19:31:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n> Hi Junio,\n>\n> On Wed, May 06, 2020 at 01:18:30PM -0700, Junio C Hamano wrote:\n>> These commands take the --quiet option for their own operation, but\n>> they forget to pass the option down when they invoke \"git gc --auto\"\n>> internally.\n>>\n>> Teach them to do so using the run_auto_gc() helper we added in the\n>> previous step.\n>>\n>> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n>> ---\n>>  builtin/am.c     | 3 +--\n>>  builtin/commit.c | 3 +--\n>>  builtin/merge.c  | 3 +--\n>>  builtin/rebase.c | 3 +--\n>>  4 files changed, 4 insertions(+), 8 deletions(-)\n>\n> Very nicely done. Sorry that these took me a little while to look at.\n> This and the patch before it both have my:\n>\n>   Reviewed-by: Taylor Blau <me@ttaylorr.com>\n>\n> Thanks,\n> Taylor\n\nThanks.\n"}]}