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

[PATCH V2 1/2] bisect_next_all: convert xsnprintf to xstrfmt

From
Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
Date
Feb 16, 2017, 17:07 UTC
Message-ID
<20170216170713.10065-2-franchesko.salias.hudro.pedros@gmail.com>
In-Reply-To
<20170216170713.10065-1-franchesko.salias.hudro.pedros@gmail.com>

Git can't run bisect between 2048+ commits if use russian translation. Reproduce "LANG=ru_RU.UTF8 git bisect start v4.9 v4.8" on linux sources.

Dummy solution: just increase buffer size but is not safe. Size gettext string is a runtime value.

Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>
---
 bisect.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/bisect.c b/bisect.c
index 21bc6daa4..787543cad 100644
--- a/bisect.c
+++ b/bisect.c
@@ -940,7 +940,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
 	struct commit_list *tried;
 	int reaches = 0, all = 0, nr, steps;
 	const unsigned char *bisect_rev;
-	char steps_msg[32];
+	char *steps_msg;
 
 	read_bisect_terms(&term_bad, &term_good);
 	if (read_bisect_refs())
@@ -990,14 +990,15 @@ int bisect_next_all(const char *prefix, int no_checkout)
 
 	nr = all - reaches - 1;
 	steps = estimate_bisect_steps(all);
-	xsnprintf(steps_msg, sizeof(steps_msg),
-		  Q_("(roughly %d step)", "(roughly %d steps)", steps),
-		  steps);
+
+	steps_msg = xstrfmt(Q_("(roughly %d step)", "(roughly %d steps)",
+		  steps), steps);
 	/* TRANSLATORS: the last %s will be replaced with
 	   "(roughly %d steps)" translation */
 	printf(Q_("Bisecting: %d revision left to test after this %s\n",
 		  "Bisecting: %d revisions left to test after this %s\n",
 		  nr), nr, steps_msg);
+	free(steps_msg);
 
 	return bisect_checkout(bisect_rev, no_checkout);
 }
-- 
2.11.1
Previous: Maxim MoseychukNext: Maxim Moseychuk
Message 2 of 6 in “Fix l10n”
  1. 0/2 Fix l10nMaxim Moseychuk, Feb 16, 2017
  2. 1/2 bisect_next_all: convert xsnprintf to xstrfmtMaxim Moseychuk, Feb 16, 2017
  3. 2/2 stop_progress_msg: convert xsnprintf to xstrfmtMaxim Moseychuk, Feb 16, 2017
  4. Junio C HamanoFeb 16, 2017
  5. UnknownFeb 16, 2017
  6. Junio C HamanoFeb 17, 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.