return run_command(&cmd);
}
+static int maintenance_task_worktree_prune(struct maintenance_run_opts *opts UNUSED,
+ struct gc_config *cfg)
+{
+ struct child_process prune_worktrees_cmd = CHILD_PROCESS_INIT;
+
+ prune_worktrees_cmd.git_cmd = 1;
+ strvec_pushl(&prune_worktrees_cmd.args, "worktree", "prune", "--expire", NULL);
+ strvec_push(&prune_worktrees_cmd.args, cfg->prune_worktrees_expire);
+
+ return run_command(&prune_worktrees_cmd);
+}
+
static int too_many_loose_objects(struct gc_config *cfg)
{
/*
}
}
- if (cfg.prune_worktrees_expire) {
- struct child_process prune_worktrees_cmd = CHILD_PROCESS_INIT;
-
- prune_worktrees_cmd.git_cmd = 1;
- strvec_pushl(&prune_worktrees_cmd.args, "worktree", "prune", "--expire", NULL);
- strvec_push(&prune_worktrees_cmd.args, cfg.prune_worktrees_expire);
-
- if (run_command(&prune_worktrees_cmd))
- die(FAILED_RUN, prune_worktrees_cmd.args.v[0]);
- }
+ if (cfg.prune_worktrees_expire &&
+ maintenance_task_worktree_prune(&opts, &cfg))
+ die(FAILED_RUN, "worktree");
rerere_cmd.git_cmd = 1;
strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL);