mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
builtin/gc: move pruning of worktrees into a separate function
In a subsequent commit we will introduce a new "worktree-prune" task for git-maintenance(1). To prepare for this, refactor the code that spawns `git worktree prune` into a separate function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e3a69d72b1
commit
ae76c1c990
25
builtin/gc.c
25
builtin/gc.c
@@ -333,6 +333,18 @@ static int maintenance_task_reflog_expire(struct maintenance_run_opts *opts UNUS
|
|||||||
return run_command(&cmd);
|
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)
|
static int too_many_loose_objects(struct gc_config *cfg)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -913,16 +925,9 @@ int cmd_gc(int argc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.prune_worktrees_expire) {
|
if (cfg.prune_worktrees_expire &&
|
||||||
struct child_process prune_worktrees_cmd = CHILD_PROCESS_INIT;
|
maintenance_task_worktree_prune(&opts, &cfg))
|
||||||
|
die(FAILED_RUN, "worktree");
|
||||||
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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rerere_cmd.git_cmd = 1;
|
rerere_cmd.git_cmd = 1;
|
||||||
strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL);
|
strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user