Skip to content

Commit f7bc30f

Browse files
pks-tgitster
authored andcommitted
builtin/gc: move rerere garbage collection into separate function
Move garbage collection of cached rerere entries into a separate function. This prepares us for a subsequent commit where we introduce a new "rerere-gc" task for git-maintenance(1). Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 91b34c4 commit f7bc30f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

builtin/gc.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ static int worktree_prune_condition(struct gc_config *cfg)
385385
return should_prune;
386386
}
387387

388+
static int maintenance_task_rerere_gc(struct maintenance_run_opts *opts UNUSED,
389+
struct gc_config *cfg UNUSED)
390+
{
391+
struct child_process rerere_cmd = CHILD_PROCESS_INIT;
392+
rerere_cmd.git_cmd = 1;
393+
strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL);
394+
return run_command(&rerere_cmd);
395+
}
396+
388397
static int too_many_loose_objects(struct gc_config *cfg)
389398
{
390399
/*
@@ -786,7 +795,6 @@ int cmd_gc(int argc,
786795
int daemonized = 0;
787796
int keep_largest_pack = -1;
788797
timestamp_t dummy;
789-
struct child_process rerere_cmd = CHILD_PROCESS_INIT;
790798
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
791799
struct gc_config cfg = GC_CONFIG_INIT;
792800
const char *prune_expire_sentinel = "sentinel";
@@ -969,10 +977,8 @@ int cmd_gc(int argc,
969977
maintenance_task_worktree_prune(&opts, &cfg))
970978
die(FAILED_RUN, "worktree");
971979

972-
rerere_cmd.git_cmd = 1;
973-
strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL);
974-
if (run_command(&rerere_cmd))
975-
die(FAILED_RUN, rerere_cmd.args.v[0]);
980+
if (maintenance_task_rerere_gc(&opts, &cfg))
981+
die(FAILED_RUN, "rerere");
976982

977983
report_garbage = report_pack_garbage;
978984
reprepare_packed_git(the_repository);

0 commit comments

Comments
 (0)