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

[PATCH 2/2] wt-status: simplify building of summary limit argument

From
René Scharfe <l.s.r@web.de>
Date
Jun 29, 2014, 20:55 UTC
Message-ID
<53B07D50.9050805@web.de>
In-Reply-To
<53B07B44.9000406@web.de>

Use argv_array_pushf for building the number string for the option --summary-limit directly instead of using an intermediate buffer.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 wt-status.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 2c0bff8..882cfe9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -734,7 +734,6 @@ static void wt_status_print_changed(struct wt_status *s)
 static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
 {
 	struct child_process sm_summary;
-	char summary_limit[64];
 	struct argv_array env = ARGV_ARRAY_INIT;
 	struct argv_array argv = ARGV_ARRAY_INIT;
 	struct strbuf cmd_stdout = STRBUF_INIT;
@@ -742,7 +741,6 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
 	char *summary_content;
 	size_t len;
 
-	sprintf(summary_limit, "%d", s->submodule_summary);
 	argv_array_pushf(&env, "GIT_INDEX_FILE=%s", s->index_file);
 
 	argv_array_push(&argv, "submodule");
@@ -750,7 +748,7 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
 	argv_array_push(&argv, uncommitted ? "--files" : "--cached");
 	argv_array_push(&argv, "--for-status");
 	argv_array_push(&argv, "--summary-limit");
-	argv_array_push(&argv, summary_limit);
+	argv_array_pushf(&argv, "%d", s->submodule_summary);
 	if (!uncommitted)
 		argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD");
 
-- 
2.0.0
Previous: René ScharfeNext: Matthieu Moy
Message 2 of 3 in “wt-status: use argv_array for environment”
  1. 1/2 wt-status: use argv_array for environmentRené Scharfe, Jun 29, 2014
  2. 2/2 wt-status: simplify building of summary limit argumentRené Scharfe, Jun 29, 2014
  3. Matthieu MoyJul 1, 2014

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.