diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-04-08 08:22:16 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-04-08 07:53:27 -0700 |
| commit | 3fef24ac3fbcc6ad9e325a293b59ee38645f2407 (patch) | |
| tree | 15d1e27d90dd219e2fe274a65662807b649b6b1b /builtin | |
| parent | builtin/reflog: make functions regarding `reflog_expire_options` public (diff) | |
| download | git-3fef24ac3fbcc6ad9e325a293b59ee38645f2407.tar.gz git-3fef24ac3fbcc6ad9e325a293b59ee38645f2407.zip | |
builtin/gc: split out function to expire reflog entries
We're about to introduce a new task for git-maintenance(1) that knows to
expire reflog entries. The logic will be shared with git-gc(1), which
already knows how to do this.
Pull out the common logic into a separate function so that we can share
the implementation between both builtins.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/gc.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/builtin/gc.c b/builtin/gc.c index 409d454a4b..e8f5705dc5 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -53,7 +53,6 @@ static const char * const builtin_gc_usage[] = { static timestamp_t gc_log_expire_time; -static struct strvec reflog = STRVEC_INIT; static struct strvec repack = STRVEC_INIT; static struct strvec prune = STRVEC_INIT; static struct strvec prune_worktrees = STRVEC_INIT; @@ -286,6 +285,15 @@ static int maintenance_task_pack_refs(struct maintenance_run_opts *opts, return run_command(&cmd); } +static int maintenance_task_reflog_expire(struct maintenance_run_opts *opts UNUSED, + struct gc_config *cfg UNUSED) +{ + struct child_process cmd = CHILD_PROCESS_INIT; + cmd.git_cmd = 1; + strvec_pushl(&cmd.args, "reflog", "expire", "--all", NULL); + return run_command(&cmd); +} + static int too_many_loose_objects(struct gc_config *cfg) { /* @@ -662,15 +670,8 @@ static void gc_before_repack(struct maintenance_run_opts *opts, if (cfg->pack_refs && maintenance_task_pack_refs(opts, cfg)) die(FAILED_RUN, "pack-refs"); - - if (cfg->prune_reflogs) { - struct child_process cmd = CHILD_PROCESS_INIT; - - cmd.git_cmd = 1; - strvec_pushv(&cmd.args, reflog.v); - if (run_command(&cmd)) - die(FAILED_RUN, reflog.v[0]); - } + if (cfg->prune_reflogs && maintenance_task_reflog_expire(opts, cfg)) + die(FAILED_RUN, "reflog"); } int cmd_gc(int argc, @@ -718,7 +719,6 @@ struct repository *repo UNUSED) show_usage_with_options_if_asked(argc, argv, builtin_gc_usage, builtin_gc_options); - strvec_pushl(&reflog, "reflog", "expire", "--all", NULL); strvec_pushl(&repack, "repack", "-d", "-l", NULL); strvec_pushl(&prune, "prune", "--expire", NULL); strvec_pushl(&prune_worktrees, "worktree", "prune", "--expire", NULL); |
