diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-05-07 09:21:41 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-07 10:50:15 -0700 |
| commit | 255251cce179efffe6dd17bc26f2729f6fcfd3bd (patch) | |
| tree | bcd41648d71e71399eee2b8d345da9e012c4a43c | |
| parent | ec31474656de3849fb9ed31f238fabdb6a59f1b1 (diff) | |
| download | git-255251cce179efffe6dd17bc26f2729f6fcfd3bd.tar.gz | |
builtin/gc: move rerere garbage collection into separate function
In a subsequent commit we are going to introduce a new "rerere-gc" task
for git-maintenance(1). To prepare for this, refactor the code that
spawns `git rerere gc` into a separate function.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | builtin/gc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin/gc.c b/builtin/gc.c index d28c238a80..03b4e32bb5 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -384,6 +384,15 @@ out: return should_prune; } +static int maintenance_task_rerere_gc(struct maintenance_run_opts *opts UNUSED, + struct gc_config *cfg UNUSED) +{ + struct child_process rerere_cmd = CHILD_PROCESS_INIT; + rerere_cmd.git_cmd = 1; + strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL); + return run_command(&rerere_cmd); +} + static int too_many_loose_objects(struct gc_config *cfg) { /* @@ -785,7 +794,6 @@ int cmd_gc(int argc, int daemonized = 0; int keep_largest_pack = -1; timestamp_t dummy; - struct child_process rerere_cmd = CHILD_PROCESS_INIT; struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT; struct gc_config cfg = GC_CONFIG_INIT; const char *prune_expire_sentinel = "sentinel"; @@ -968,10 +976,8 @@ int cmd_gc(int argc, maintenance_task_worktree_prune(&opts, &cfg)) die(FAILED_RUN, "worktree"); - rerere_cmd.git_cmd = 1; - strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL); - if (run_command(&rerere_cmd)) - die(FAILED_RUN, rerere_cmd.args.v[0]); + if (maintenance_task_rerere_gc(&opts, &cfg)) + die(FAILED_RUN, "rerere"); report_garbage = report_pack_garbage; reprepare_packed_git(the_repository); |
