Skip to contentSkip to conversation

commit: silence git-gc if --quiet is given

PATCH In review Abhishek Kumar 3 participants 3 messages May 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commit: silence git-gc if --quiet is given

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/

---
 builtin/commit.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
builtin/commit.c +6 -2
index a73de0a4c5..a48e312ebd 100644
@@ -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);
Signature · 1 line
2.26.0
#1 lore raw
Quoted 4 lines · Abhishek Kumar

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/

According to the source you cite, this sort of issue has come up before in a different context (git-fetch). Do we know if there are other commands which invoke git-gc which might also suffer the same issue? It would be nice for the commit message to say something about this... for instance, that git-commit is the final command which needs this fix or, if not, which additional commands are likely to need the same treatment.

Quoted 2 lines
#2 lore raw
Quoted 11 lines · Eric Sunshine
Quoted 4 lines · Abhishek Kumar

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/

According to the source you cite, this sort of issue has come up before in a different context (git-fetch). Do we know if there are other commands which invoke git-gc which might also suffer the same issue?

I just wrote my analysis to the original thread. It looks to me a fairly low-hanging fruit.