git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] midx: use strvec_pushf() for pack-objects base name

From
René Scharfe <l.s.r@web.de>
Date
Mar 24, 2024, 16:40 UTC
Message-ID
<9483038c-9529-4243-9b9a-97254fac29c1@web.de>

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>
---
 midx.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/midx.c b/midx.c
index 85e1c2cd12..41521e019c 100644
--- a/midx.c
+++ b/midx.c
@@ -2163,7 +2163,6 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
 	unsigned char *include_pack;
 	struct child_process cmd = CHILD_PROCESS_INIT;
 	FILE *cmd_in;
-	struct strbuf base_name = STRBUF_INIT;
 	struct multi_pack_index *m = lookup_multi_pack_index(r, object_dir);

 	/*
@@ -2190,9 +2189,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,

 	strvec_push(&cmd.args, "pack-objects");

-	strbuf_addstr(&base_name, object_dir);
-	strbuf_addstr(&base_name, "/pack/pack");
-	strvec_push(&cmd.args, base_name.buf);
+	strvec_pushf(&cmd.args, "%s/pack/pack", object_dir);

 	if (delta_base_offset)
 		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,
 	else
 		strvec_push(&cmd.args, "-q");

-	strbuf_release(&base_name);
-
 	cmd.git_cmd = 1;
 	cmd.in = cmd.out = -1;

--
2.44.0
Next: Patrick Steinhardt
Message 1 of 2 in “midx: use strvec_pushf() for pack-objects base name”
  1. midx: use strvec_pushf() for pack-objects base nameRené Scharfe, Mar 24, 2024
  2. Patrick SteinhardtMar 25, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.