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

[Outreachy PATCH v2] checkout: use Q_() for messages with counts

From
TJTanga Joris <tangajoris@gmail.com>
Date
Oct 22, 2026, 00:48 UTC
Message-ID
<20261022004834.246892-1-tangajoris@gmail.com>
In-Reply-To
<20261021022156.119947-1-tangajoris@gmail.com>

Two messages in builtin/checkout.c show a count but are marked with a plain _(), so translators can only give a single form for them:

- " ... and %d more." at the end of the list of orphaned
  commits left behind when leaving a detached HEAD, and
- "only one reference expected, %d given." when more than
  one reference is given before "--".

Use Q_() for both. Translators of a language that phrases "2 more" and "3 more" the same way now have to translate these messages twice. At that cost, however, we help translators of languages that need to phrase "2 more", "3 more", and "5 more" differently.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Tanga Joris <tangajoris@gmail.com>
---
Changes since v1:
 - Replaced the last sentence of the log message with
   a better explanation of the trade-off.
 - Also converted "only one reference expected, %d given.",
   as discussed by Tuomas in Mudi's thread.
Interdiff against v1:
  diff --git a/builtin/checkout.c b/builtin/checkout.c
  index 49239f029f..91b7c52396 100644
  --- a/builtin/checkout.c
  +++ b/builtin/checkout.c
  @@ -1491,7 +1491,9 @@ static int parse_branchname_arg(int argc, const char **argv,
   	else if (dash_dash_pos == 1)
   		has_dash_dash = 1; /* case (3) or (1) */
   	else if (dash_dash_pos >= 2)
  -		die(_("only one reference expected, %d given."), dash_dash_pos);
  +		die(Q_("only one reference expected, %d given.",
  +		       "only one reference expected, %d given.",
  +		       dash_dash_pos), dash_dash_pos);
   	opts->count_checkout_paths = !opts->quiet && !has_dash_dash;
   
   	if (!strcmp(arg, "-"))
 builtin/checkout.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2d575a4f57..91b7c52396 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1085,7 +1085,9 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
 		if (more == 1)
 			describe_one_orphan(&sb, last);
 		else
-			strbuf_addf(&sb, _(" ... and %d more.\n"), more);
+			strbuf_addf(&sb, Q_(" ... and %d more.\n",
+					    " ... and %d more.\n",
+					    more), more);
 	}
 
 	fprintf(stderr,
@@ -1489,7 +1491,9 @@ static int parse_branchname_arg(int argc, const char **argv,
 	else if (dash_dash_pos == 1)
 		has_dash_dash = 1; /* case (3) or (1) */
 	else if (dash_dash_pos >= 2)
-		die(_("only one reference expected, %d given."), dash_dash_pos);
+		die(Q_("only one reference expected, %d given.",
+		       "only one reference expected, %d given.",
+		       dash_dash_pos), dash_dash_pos);
 	opts->count_checkout_paths = !opts->quiet && !has_dash_dash;
 
 	if (!strcmp(arg, "-"))
-- 
2.43.0
Previous: Tanga JorisNext: Junio C Hamano
Message 4 of 5 in “checkout: use Q_() for the "... and %d more" message”
  1. checkout: use Q_() for the "... and %d more" messageTanga Joris, Oct 21, 2026
  2. Junio C HamanoOct 21, 2026
  3. Tanga JorisOct 21, 2026
  4. checkout: use Q_() for messages with countsTanga Joris, Oct 22, 2026
  5. Junio C HamanoOct 23, 2026

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.