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

[PATCH] commit: use strbuf_add() to add a length-limited string

From
René Scharfe <l.s.r@web.de>
Date
Dec 7, 2019, 11:16 UTC
Message-ID
<f4c7d65f-d7bb-c574-fe48-8d2df0c2907a@web.de>
This is shorter and simpler.
Signed-off-by: René 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 294dc574cd..35a1fb9ad6 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -537,7 +537,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.24.0
Next: Derrick Stolee
Message 1 of 3 in “commit: use strbuf_add() to add a length-limited string”
  1. commit: use strbuf_add() to add a length-limited stringRené Scharfe, Dec 7, 2019
  2. Derrick StoleeDec 7, 2019
  3. Junio C HamanoDec 9, 2019

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.