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

[PATCH 2/2] commit: use strbuf_add() to add a buffer to a strbuf

From
René Scharfe <l.s.r@web.de>
Date
Oct 1, 2017, 14:54 UTC
Message-ID
<223ef0c8-dac2-747b-41c8-3bad62f4c274@web.de>
In-Reply-To
<85605bc6-2e91-7132-ce63-f6e08a08a768@web.de>
This is shorter, easier and makes the intent clearer.
Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/commit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 0f8ddb6866..d186736617 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -542,7 +542,7 @@ static void export_one(const char *var, const char *s, const char *e, int hack)
 	struct strbuf buf = STRBUF_INIT;
 	if (hack)
 		strbuf_addch(&buf, hack);
-	strbuf_addf(&buf, "%.*s", (int)(e - s), s);
+	strbuf_add(&buf, s, e - s);
 	setenv(var, buf.buf, 1);
 	strbuf_release(&buf);
 }
-- 
2.14.2
Previous: René ScharfeNext: Jeff King
Message 2 of 3 in “coccinelle: add rules to use strbuf_add() for adding buffers to strbufs”
  1. 1/2 coccinelle: add rules to use strbuf_add() for adding buffers to strbufsRené Scharfe, Oct 1, 2017
  2. 2/2 commit: use strbuf_add() to add a buffer to a strbufRené Scharfe, Oct 1, 2017
  3. Jeff KingOct 2, 2017

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.