threads / patch / 66652

v2object-name: use Q_() for the reflog entry count

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

## tl;dr

2 messages between Oct 24, 2026 and Oct 25, 2026. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Aniket Gupta· Oct 24, 2026, 15:29 UTC · lore

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>
---
Changes since v1: t1506 was also looking for "entries" and thus
failed with a one-entry reflog. Now it matches "entr" just like Junio
suggested
v1: https://lore.kernel.org/git/20261023133118.456-1-aniketgupta3001@gmail.com/
 object-name.c                  |  4 +++-
 t/t1400-update-ref.sh          | 14 ++++++++++++++
 t/t1506-rev-parse-diagnosis.sh |  4 ++--
 3 files changed, 19 insertions(+), 3 deletions(-)
Show changes to 3 files +19 −3

object-name.c, t/t1400-update-ref.sh, t/t1506-rev-parse-diagnosis.sh

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 &&
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 722884e65..9a4b93b79 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -142,10 +142,10 @@ test_expect_success 'incorrect file in :path and :N:path' '
 test_expect_success 'invalid @{n} reference' '
 	test_must_fail git rev-parse main@{99999} >output 2>error &&
 	test_must_be_empty output &&
-	test_grep "log for [^ ]* only has [0-9][0-9]* entries" error  &&
+	test_grep "log for [^ ]* only has [0-9][0-9]* entr" error &&
 	test_must_fail git rev-parse --verify main@{99999} >output 2>error &&
 	test_must_be_empty output &&
-	test_grep "log for [^ ]* only has [0-9][0-9]* entries" error
+	test_grep "log for [^ ]* only has [0-9][0-9]* entr" error
 '
 
 test_expect_success 'relative path not found' '
-- 
2.43.0
Junio C Hamano· Oct 25, 2026, 04:26 UTC · re: Aniket Gupta · lore

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

Aniket Gupta <aniketgupta3001@gmail.com> writes:
Show 16 quoted lines
> 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>
> ---
> Changes since v1: t1506 was also looking for "entries" and thus
> failed with a one-entry reflog. Now it matches "entr" just like Junio
> suggested
>
> v1: https://lore.kernel.org/git/20261023133118.456-1-aniketgupta3001@gmail.com/
Your v2 must be a reply to your v1 message.

← back to recent threads