From: Aniket Gupta <aniketgupta3001@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [GSoC PATCH] object-name: use Q_() for the reflog entry count
Date: Fri, 23 Oct 2026 13:31:18 +0000 [thread overview]
Message-ID: <20261023133118.456-1-aniketgupta3001@gmail.com> (raw)
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 reply other threads:[~2026-10-23 13:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 13:31 Aniket Gupta [this message]
2026-10-24 1:36 ` [GSoC PATCH] object-name: use Q_() for the reflog entry count Junio C Hamano
2026-10-24 2:02 ` Junio C Hamano
2026-10-25 6:12 ` [GSoC PATCH v2] " Aniket Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023133118.456-1-aniketgupta3001@gmail.com \
--to=aniketgupta3001@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox