* [GSoC PATCH] object-name: use Q_() for the reflog entry count
@ 2026-10-23 13:31 Aniket Gupta
2026-10-24 1:36 ` Junio C Hamano
2026-10-25 6:12 ` [GSoC PATCH v2] " Aniket Gupta
0 siblings, 2 replies; 4+ messages in thread
From: Aniket Gupta @ 2026-10-23 13:31 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [GSoC PATCH] object-name: use Q_() for the reflog entry count
2026-10-23 13:31 [GSoC PATCH] object-name: use Q_() for the reflog entry count Aniket Gupta
@ 2026-10-24 1:36 ` Junio C Hamano
2026-10-24 2:02 ` Junio C Hamano
2026-10-25 6:12 ` [GSoC PATCH v2] " Aniket Gupta
1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2026-10-24 1:36 UTC (permalink / raw)
To: Aniket Gupta; +Cc: git
Aniket Gupta <aniketgupta3001@gmail.com> writes:
> 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 &&
Obviously there are existing tests that cover this message already,
and without adjusting them, the test suite would not pass with this
patch applied.
$ make >/dev/null 2>&1 && cd t && sh ./t1506-rev*.sh -i -v
Initialized empty Git repository in .git/
expecting success of 1506.1 'set up basic repo':
echo one > file.txt &&
mkdir subdir &&
echo two > subdir/file.txt &&
echo three > subdir/file2.txt &&
git add . &&
git commit -m init &&
echo four > index-only.txt &&
git add index-only.txt &&
echo five > disk-only.txt
...
ok 12 - incorrect file in :path and :N:path
expecting success of 1506.13 '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_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
error: 'grep log for [^ ]* only has [0-9][0-9]* entries error' didn't find a match in:
fatal: log for 'main' only has 1 entry
not ok 13 - 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_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
#
1..13
It could be that t1506 is the only one that needs adjusting.
$ git grep -n -e 'only has.*entries' -- :/t
t/t1400-update-ref.sh:471: echo "fatal: log for ${SQ}main${SQ} only has 2 entries" >expect &&
t/t1506-rev-parse-diagnosis.sh:145: test_grep "log for [^ ]* only has [0-9][0-9]* entries" error &&
t/t1506-rev-parse-diagnosis.sh:148: test_grep "log for [^ ]* only has [0-9][0-9]* entries" error
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [GSoC PATCH] object-name: use Q_() for the reflog entry count
2026-10-24 1:36 ` Junio C Hamano
@ 2026-10-24 2:02 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2026-10-24 2:02 UTC (permalink / raw)
To: Aniket Gupta; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> not ok 13 - 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_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
> #
> 1..13
>
> It could be that t1506 is the only one that needs adjusting.
>
> $ git grep -n -e 'only has.*entries' -- :/t
> t/t1400-update-ref.sh:471: echo "fatal: log for ${SQ}main${SQ} only has 2 entries" >expect &&
> t/t1506-rev-parse-diagnosis.sh:145: test_grep "log for [^ ]* only has [0-9][0-9]* entries" error &&
> t/t1506-rev-parse-diagnosis.sh:148: test_grep "log for [^ ]* only has [0-9][0-9]* entries" error
The fix may look like this. With the extra commit disabled, the
reflog has only 1 entry and "entries" no longer match (hence the
pattern truncated to "entr"), and if you remove the leading ':'
colon, the extra commit will grow the reflog by one entry, so the
message will use the "entries" form. As you have added a new test
to cover both singular and plural elsewhere, we may not have to make
this test so thorough, so if you are going to take it, I'd recommend
removing the extra commit.
t/t1506-rev-parse-diagnosis.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git c/t/t1506-rev-parse-diagnosis.sh w/t/t1506-rev-parse-diagnosis.sh
index 722884e65f..e4dade392e 100755
--- c/t/t1506-rev-parse-diagnosis.sh
+++ w/t/t1506-rev-parse-diagnosis.sh
@@ -140,12 +140,13 @@ test_expect_success 'incorrect file in :path and :N:path' '
'
test_expect_success 'invalid @{n} reference' '
+ : git commit --allow-empty -m 'void' &&
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 [1-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 [1-9][0-9]* entr" error
'
test_expect_success 'relative path not found' '
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [GSoC PATCH v2] object-name: use Q_() for the reflog entry count
2026-10-23 13:31 [GSoC PATCH] object-name: use Q_() for the reflog entry count Aniket Gupta
2026-10-24 1:36 ` Junio C Hamano
@ 2026-10-25 6:12 ` Aniket Gupta
1 sibling, 0 replies; 4+ messages in thread
From: Aniket Gupta @ 2026-10-25 6:12 UTC (permalink / raw)
To: git; +Cc: gitster
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>
---
Resend of v2, now sent as a reply to v1. No other changes.
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(-)
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-25 6:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23 13:31 [GSoC PATCH] object-name: use Q_() for the reflog entry count Aniket Gupta
2026-10-24 1:36 ` Junio C Hamano
2026-10-24 2:02 ` Junio C Hamano
2026-10-25 6:12 ` [GSoC PATCH v2] " Aniket Gupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox