Skip to content

Commit bd19b94

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 95b5039 commit bd19b94

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

builtin/gc.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ int cmd_gc(int argc,
818818
struct repository *repo UNUSED)
819819
{
820820
int aggressive = 0;
821-
int quiet = 0;
822821
int force = 0;
823822
const char *name;
824823
pid_t pid;
@@ -831,7 +830,7 @@ int cmd_gc(int argc,
831830
const char *prune_expire_arg = prune_expire_sentinel;
832831
int ret;
833832
struct option builtin_gc_options[] = {
834-
OPT__QUIET(&quiet, N_("suppress progress reporting")),
833+
OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
835834
{
836835
.type = OPTION_STRING,
837836
.long_name = "prune",
@@ -891,7 +890,7 @@ int cmd_gc(int argc,
891890
if (cfg.aggressive_window > 0)
892891
strvec_pushf(&repack, "--window=%d", cfg.aggressive_window);
893892
}
894-
if (quiet)
893+
if (opts.quiet)
895894
strvec_push(&repack, "-q");
896895

897896
if (opts.auto_flag) {
@@ -906,7 +905,7 @@ int cmd_gc(int argc,
906905
goto out;
907906
}
908907

909-
if (!quiet) {
908+
if (!opts.quiet) {
910909
if (opts.detach > 0)
911910
fprintf(stderr, _("Auto packing the repository in background for optimum performance.\n"));
912911
else
@@ -991,7 +990,7 @@ int cmd_gc(int argc,
991990
strvec_pushl(&prune_cmd.args, "prune", "--expire", NULL);
992991
/* run `git prune` even if using cruft packs */
993992
strvec_push(&prune_cmd.args, cfg.prune_expire);
994-
if (quiet)
993+
if (opts.quiet)
995994
strvec_push(&prune_cmd.args, "--no-progress");
996995
if (repo_has_promisor_remote(the_repository))
997996
strvec_push(&prune_cmd.args,
@@ -1019,7 +1018,7 @@ int cmd_gc(int argc,
10191018

10201019
if (the_repository->settings.gc_write_commit_graph == 1)
10211020
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,
10231022
NULL);
10241023

10251024
if (opts.auto_flag && too_many_loose_objects(&cfg))

0 commit comments

Comments
 (0)