]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gc: simplify maintenance_task_pack_refs()
authorRené Scharfe <l.s.r@web.de>
Tue, 4 Oct 2022 16:17:39 +0000 (18:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Oct 2022 19:46:27 +0000 (12:46 -0700)
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>
builtin/gc.c

index 2753bd15a5e85f584a0e73943828ce8cd1d0fe5c..ceff31ea002b873e8e2e18cdd965aa47f4ddabbc 100644 (file)
@@ -167,16 +167,9 @@ static void gc_config(void)
 struct maintenance_run_opts;
 static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
 {
-       struct strvec pack_refs_cmd = STRVEC_INIT;
-       int ret;
+       const char *argv[] = { "pack-refs", "--all", "--prune", NULL };
 
-       strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
-
-       ret = run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD);
-
-       strvec_clear(&pack_refs_cmd);
-
-       return ret;
+       return run_command_v_opt(argv, RUN_GIT_CMD);
 }
 
 static int too_many_loose_objects(void)