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

[GSoC PATCH] object-name: use Q_() for the reflog entry count

From
AGAniket Gupta <aniketgupta3001@gmail.com>
Date
Oct 23, 2026, 13:31 UTC
Message-ID
<20261023133118.456-1-aniketgupta3001@gmail.com>

When reflog is asked for an entry that it doesnt have, for eg with "HEAD@{5}" get_oid_basic() reports how many entries the log has. The message is not marked for plural forms and a log with one entry says that "only has 1 entries"

Use Q_() so that the singular is used for one entry so that translations for languages with other plural forms also can have the right form for each count.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 object-name.c         |  4 +++-
 t/t1400-update-ref.sh | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/object-name.c b/object-name.c
index 654668576..eeaac2ddc 100644
--- a/object-name.c
+++ b/object-name.c
@@ -810,7 +810,9 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
 				if (flags & GET_OID_QUIETLY) {
 					exit(128);
 				}
-				die(_("log for '%.*s' only has %d entries"),
+				die(Q_("log for '%.*s' only has %d entry",
+				       "log for '%.*s' only has %d entries",
+				       co_cnt),
 				    len, str, co_cnt);
 			}
 			if (flags & GET_OID_GENTLY) {
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 1a164c96f..1d1b46379 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -458,6 +458,20 @@ test_expect_success 'query reflog with gap' '
 	test_grep -F "warning: log for ref $m has gap after $gd" stderr
 '
 
+test_expect_success 'reflog entry out of range reports how many there are' '
+	test_when_finished "git update-ref -d $m" &&
+
+	GIT_COMMITTER_DATE="1117150320 -0500" git update-ref $m $A &&
+	test_must_fail git rev-parse --verify "main@{5}" 2>actual &&
+	echo "fatal: log for ${SQ}main${SQ} only has 1 entry" >expect &&
+	test_cmp expect actual &&
+
+	GIT_COMMITTER_DATE="1117150380 -0500" git update-ref $m $B &&
+	test_must_fail git rev-parse --verify "main@{5}" 2>actual &&
+	echo "fatal: log for ${SQ}main${SQ} only has 2 entries" >expect &&
+	test_cmp expect actual
+'
+
 test_expect_success 'creating initial files' '
 	test_when_finished rm -f M &&
 	echo TEST >F &&
-- 
2.43.0
Next: Junio C Hamano
Message 1 of 4 in “object-name: use Q_() for the reflog entry count”
  1. object-name: use Q_() for the reflog entry countAniket Gupta, Oct 23, 2026
  2. Junio C HamanoOct 24, 2026
  3. Junio C HamanoOct 24, 2026
  4. object-name: use Q_() for the reflog entry countAniket Gupta, Oct 25, 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.