Skip to content

Commit b004c90

Browse files
rscharfegitster
authored andcommitted
gc: simplify maintenance_task_pack_refs()
Pass a constant string array directly to run_command_v_opt() instead of copying it into a strvec first. This shortens the code and avoids heap allocations. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3dcec76 commit b004c90

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

builtin/gc.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,9 @@ static void gc_config(void)
167167
struct maintenance_run_opts;
168168
static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
169169
{
170-
struct strvec pack_refs_cmd = STRVEC_INIT;
171-
int ret;
170+
const char *argv[] = { "pack-refs", "--all", "--prune", NULL };
172171

173-
strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
174-
175-
ret = run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD);
176-
177-
strvec_clear(&pack_refs_cmd);
178-
179-
return ret;
172+
return run_command_v_opt(argv, RUN_GIT_CMD);
180173
}
181174

182175
static int too_many_loose_objects(void)

0 commit comments

Comments
 (0)