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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 4, 2022 at 18:17 UTC b004c9028270832aec73746fdddd5c7bce8dbe84
1 file changed +2 -9
builtin/gc.c
+2 -9
@@ -167,16 +167,9 @@ static void gc_config(void)
167 struct maintenance_run_opts;
168 static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
169 {
170 - struct strvec pack_refs_cmd = STRVEC_INIT;
171 - int ret;
170 + const char *argv[] = { "pack-refs", "--all", "--prune", NULL };
171
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);
173 }
174
175 static int too_many_loose_objects(void)