builtin/gc: drop redundant local variable

We have two different variables that track the quietness for git-gc(1): - The local variable `quiet`, which we wire up. - The `quiet` field of `struct maintenance_run_opts`. This leads to confusion which of these variables should be used and what the respective effect is. Simplify this logic by dropping the local variable in favor of the options field. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jun 3, 2025 at 16:01 UTC bd19b94a664ee6434a5f1b9d65f3d3ee70a9188c
1 file changed +5 -6
builtin/gc.c
+5 -6
@@ -818,7 +818,6 @@ int cmd_gc(int argc,
818 struct repository *repo UNUSED)
819 {
820 int aggressive = 0;
821 - int quiet = 0;
821 int force = 0;
822 const char *name;
823 pid_t pid;
@@ -831,7 +830,7 @@ int cmd_gc(int argc,
830 const char *prune_expire_arg = prune_expire_sentinel;
831 int ret;
832 struct option builtin_gc_options[] = {
834 - OPT__QUIET(&quiet, N_("suppress progress reporting")),
833 + OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
834 {
835 .type = OPTION_STRING,
836 .long_name = "prune",
@@ -891,7 +890,7 @@ int cmd_gc(int argc,
890 if (cfg.aggressive_window > 0)
891 strvec_pushf(&repack, "--window=%d", cfg.aggressive_window);
892 }
894 - if (quiet)
893 + if (opts.quiet)
894 strvec_push(&repack, "-q");
895
896 if (opts.auto_flag) {
@@ -906,7 +905,7 @@ int cmd_gc(int argc,
905 goto out;
906 }
907
909 - if (!quiet) {
908 + if (!opts.quiet) {
909 if (opts.detach > 0)
910 fprintf(stderr, _("Auto packing the repository in background for optimum performance.\n"));
911 else
@@ -991,7 +990,7 @@ int cmd_gc(int argc,
990 strvec_pushl(&prune_cmd.args, "prune", "--expire", NULL);
991 /* run `git prune` even if using cruft packs */
992 strvec_push(&prune_cmd.args, cfg.prune_expire);
994 - if (quiet)
993 + if (opts.quiet)
994 strvec_push(&prune_cmd.args, "--no-progress");
995 if (repo_has_promisor_remote(the_repository))
996 strvec_push(&prune_cmd.args,
@@ -1019,7 +1018,7 @@ int cmd_gc(int argc,
1018
1019 if (the_repository->settings.gc_write_commit_graph == 1)
1020 write_commit_graph_reachable(the_repository->objects->odb,
1022 - !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
1021 + !opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
1022 NULL);
1023
1024 if (opts.auto_flag && too_many_loose_objects(&cfg))