midx: use strvec_pushf() for pack-objects base name
Build the pack base name argument directly using strvec_pushf() instead of with an intermediate strbuf. This is shorter, simpler and avoids the need for explicit cleanup. Signed-off-by: René Scharfe <l.s.r@web.de> Reviewed-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Mar 24, 2024 at 17:40 UTC
4d45e79e115ef3259179032367cb84d08198c6c5
1 file changed
+1
-6
midx.c
+1
-6
@@ -2163,7 +2163,6 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
2163
unsigned char *include_pack;
2164
struct child_process cmd = CHILD_PROCESS_INIT;
2165
FILE *cmd_in;
2166
- struct strbuf base_name = STRBUF_INIT;
2166
struct multi_pack_index *m = lookup_multi_pack_index(r, object_dir);
2167
2168
/*
@@ -2190,9 +2189,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
2189
2190
strvec_push(&cmd.args, "pack-objects");
2191
2193
- strbuf_addstr(&base_name, object_dir);
2194
- strbuf_addstr(&base_name, "/pack/pack");
2195
- strvec_push(&cmd.args, base_name.buf);
2192
+ strvec_pushf(&cmd.args, "%s/pack/pack", object_dir);
2193
2194
if (delta_base_offset)
2195
strvec_push(&cmd.args, "--delta-base-offset");
@@ -2204,8 +2201,6 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
2201
else
2202
strvec_push(&cmd.args, "-q");
2203
2207
- strbuf_release(&base_name);
2208
-
2204
cmd.git_cmd = 1;
2205
cmd.in = cmd.out = -1;
2206