{"thread":{"id":"66643","subject":"[GSoC PATCH] object-name: use Q_() for the reflog entry count","startedAt":"2026-10-23T13:31:18Z","lastAt":"2026-10-25T06:12:22Z","messageCount":4,"participants":["Aniket Gupta","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556034","messageId":"20261023133118.456-1-aniketgupta3001@gmail.com","threadId":"66643","inReplyTo":null,"subject":"[GSoC PATCH] object-name: use Q_() for the reflog entry count","fromName":"Aniket Gupta","fromEmail":"aniketgupta3001@gmail.com","sentAt":"2026-10-23T13:31:18Z","receivedAt":"2026-10-23T13:31:18Z","isPatch":true,"sender":{"key":"aniketgupta3001@gmail.com","avatar":null},"body":"When reflog is asked for an entry that it doesnt have, for eg with\n\"HEAD@{5}\" get_oid_basic() reports how many entries the log has. The\nmessage is not marked for plural forms and a log with one entry says\nthat \"only has 1 entries\"\n\nUse Q_() so that the singular is used for one entry so that\ntranslations for languages with other plural forms also can have the\nright form for each count.\n\nSigned-off-by: Aniket Gupta <aniketgupta3001@gmail.com>\n---\n object-name.c         |  4 +++-\n t/t1400-update-ref.sh | 14 ++++++++++++++\n 2 files changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/object-name.c b/object-name.c\nindex 654668576..eeaac2ddc 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -810,7 +810,9 @@ static int get_oid_basic(struct repository *r, const char *str, int len,\n \t\t\t\tif (flags & GET_OID_QUIETLY) {\n \t\t\t\t\texit(128);\n \t\t\t\t}\n-\t\t\t\tdie(_(\"log for '%.*s' only has %d entries\"),\n+\t\t\t\tdie(Q_(\"log for '%.*s' only has %d entry\",\n+\t\t\t\t       \"log for '%.*s' only has %d entries\",\n+\t\t\t\t       co_cnt),\n \t\t\t\t    len, str, co_cnt);\n \t\t\t}\n \t\t\tif (flags & GET_OID_GENTLY) {\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex 1a164c96f..1d1b46379 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -458,6 +458,20 @@ test_expect_success 'query reflog with gap' '\n \ttest_grep -F \"warning: log for ref $m has gap after $gd\" stderr\n '\n \n+test_expect_success 'reflog entry out of range reports how many there are' '\n+\ttest_when_finished \"git update-ref -d $m\" &&\n+\n+\tGIT_COMMITTER_DATE=\"1117150320 -0500\" git update-ref $m $A &&\n+\ttest_must_fail git rev-parse --verify \"main@{5}\" 2>actual &&\n+\techo \"fatal: log for ${SQ}main${SQ} only has 1 entry\" >expect &&\n+\ttest_cmp expect actual &&\n+\n+\tGIT_COMMITTER_DATE=\"1117150380 -0500\" git update-ref $m $B &&\n+\ttest_must_fail git rev-parse --verify \"main@{5}\" 2>actual &&\n+\techo \"fatal: log for ${SQ}main${SQ} only has 2 entries\" >expect &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'creating initial files' '\n \ttest_when_finished rm -f M &&\n \techo TEST >F &&\n-- \n2.43.0\n\n\n"},{"id":"556131","messageId":"xmqq4ieb3mnu.fsf@gitster.g","threadId":"66643","inReplyTo":"20261023133118.456-1-aniketgupta3001@gmail.com","subject":"Re: [GSoC PATCH] object-name: use Q_() for the reflog entry count","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-24T01:36:05Z","receivedAt":"2026-10-24T01:36:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aniket Gupta <aniketgupta3001@gmail.com> writes:\n\n> When reflog is asked for an entry that it doesnt have, for eg with\n> \"HEAD@{5}\" get_oid_basic() reports how many entries the log has. The\n> message is not marked for plural forms and a log with one entry says\n> that \"only has 1 entries\"\n>\n> Use Q_() so that the singular is used for one entry so that\n> translations for languages with other plural forms also can have the\n> right form for each count.\n>\n> Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>\n> ---\n>  object-name.c         |  4 +++-\n>  t/t1400-update-ref.sh | 14 ++++++++++++++\n>  2 files changed, 17 insertions(+), 1 deletion(-)\n>\n> diff --git a/object-name.c b/object-name.c\n> index 654668576..eeaac2ddc 100644\n> --- a/object-name.c\n> +++ b/object-name.c\n> @@ -810,7 +810,9 @@ static int get_oid_basic(struct repository *r, const char *str, int len,\n>  \t\t\t\tif (flags & GET_OID_QUIETLY) {\n>  \t\t\t\t\texit(128);\n>  \t\t\t\t}\n> -\t\t\t\tdie(_(\"log for '%.*s' only has %d entries\"),\n> +\t\t\t\tdie(Q_(\"log for '%.*s' only has %d entry\",\n> +\t\t\t\t       \"log for '%.*s' only has %d entries\",\n> +\t\t\t\t       co_cnt),\n>  \t\t\t\t    len, str, co_cnt);\n>  \t\t\t}\n>  \t\t\tif (flags & GET_OID_GENTLY) {\n> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\n> index 1a164c96f..1d1b46379 100755\n> --- a/t/t1400-update-ref.sh\n> +++ b/t/t1400-update-ref.sh\n> @@ -458,6 +458,20 @@ test_expect_success 'query reflog with gap' '\n>  \ttest_grep -F \"warning: log for ref $m has gap after $gd\" stderr\n>  '\n>  \n> +test_expect_success 'reflog entry out of range reports how many there are' '\n> +\ttest_when_finished \"git update-ref -d $m\" &&\n> +\n> +\tGIT_COMMITTER_DATE=\"1117150320 -0500\" git update-ref $m $A &&\n> +\ttest_must_fail git rev-parse --verify \"main@{5}\" 2>actual &&\n> +\techo \"fatal: log for ${SQ}main${SQ} only has 1 entry\" >expect &&\n> +\ttest_cmp expect actual &&\n> +\n> +\tGIT_COMMITTER_DATE=\"1117150380 -0500\" git update-ref $m $B &&\n> +\ttest_must_fail git rev-parse --verify \"main@{5}\" 2>actual &&\n> +\techo \"fatal: log for ${SQ}main${SQ} only has 2 entries\" >expect &&\n> +\ttest_cmp expect actual\n> +'\n> +\n>  test_expect_success 'creating initial files' '\n>  \ttest_when_finished rm -f M &&\n>  \techo TEST >F &&\n\nObviously there are existing tests that cover this message already,\nand without adjusting them, the test suite would not pass with this\npatch applied.\n\n$ make >/dev/null 2>&1 && cd t && sh ./t1506-rev*.sh -i -v\nInitialized empty Git repository in .git/\nexpecting success of 1506.1 'set up basic repo': \n\techo one > file.txt &&\n\tmkdir subdir &&\n\techo two > subdir/file.txt &&\n\techo three > subdir/file2.txt &&\n\tgit add . &&\n\tgit commit -m init &&\n\techo four > index-only.txt &&\n\tgit add index-only.txt &&\n\techo five > disk-only.txt\n...\nok 12 - incorrect file in :path and :N:path\n\nexpecting success of 1506.13 'invalid @{n} reference': \n\ttest_must_fail git rev-parse main@{99999} >output 2>error &&\n\ttest_must_be_empty output &&\n\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\n\ttest_must_fail git rev-parse --verify main@{99999} >output 2>error &&\n\ttest_must_be_empty output &&\n\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n\nerror: 'grep log for [^ ]* only has [0-9][0-9]* entries error' didn't find a match in:\nfatal: log for 'main' only has 1 entry\nnot ok 13 - invalid @{n} reference\n#\t\n#\t\ttest_must_fail git rev-parse main@{99999} >output 2>error &&\n#\t\ttest_must_be_empty output &&\n#\t\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\n#\t\ttest_must_fail git rev-parse --verify main@{99999} >output 2>error &&\n#\t\ttest_must_be_empty output &&\n#\t\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n#\t\n1..13\n\nIt could be that t1506 is the only one that needs adjusting.\n\n$ git grep -n -e 'only has.*entries' -- :/t\nt/t1400-update-ref.sh:471:\techo \"fatal: log for ${SQ}main${SQ} only has 2 entries\" >expect &&\nt/t1506-rev-parse-diagnosis.sh:145:\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\nt/t1506-rev-parse-diagnosis.sh:148:\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n\n\n"},{"id":"556134","messageId":"xmqqv76r26vz.fsf@gitster.g","threadId":"66643","inReplyTo":"xmqq4ieb3mnu.fsf@gitster.g","subject":"Re: [GSoC PATCH] object-name: use Q_() for the reflog entry count","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-24T02:02:08Z","receivedAt":"2026-10-24T02:02:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> not ok 13 - invalid @{n} reference\n> #\t\n> #\t\ttest_must_fail git rev-parse main@{99999} >output 2>error &&\n> #\t\ttest_must_be_empty output &&\n> #\t\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\n> #\t\ttest_must_fail git rev-parse --verify main@{99999} >output 2>error &&\n> #\t\ttest_must_be_empty output &&\n> #\t\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n> #\t\n> 1..13\n>\n> It could be that t1506 is the only one that needs adjusting.\n>\n> $ git grep -n -e 'only has.*entries' -- :/t\n> t/t1400-update-ref.sh:471:\techo \"fatal: log for ${SQ}main${SQ} only has 2 entries\" >expect &&\n> t/t1506-rev-parse-diagnosis.sh:145:\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\n> t/t1506-rev-parse-diagnosis.sh:148:\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n\nThe fix may look like this.  With the extra commit disabled, the\nreflog has only 1 entry and \"entries\" no longer match (hence the\npattern truncated to \"entr\"), and if you remove the leading ':'\ncolon, the extra commit will grow the reflog by one entry, so the\nmessage will use the \"entries\" form.  As you have added a new test\nto cover both singular and plural elsewhere, we may not have to make\nthis test so thorough, so if you are going to take it, I'd recommend\nremoving the extra commit.\n\n t/t1506-rev-parse-diagnosis.sh | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git c/t/t1506-rev-parse-diagnosis.sh w/t/t1506-rev-parse-diagnosis.sh\nindex 722884e65f..e4dade392e 100755\n--- c/t/t1506-rev-parse-diagnosis.sh\n+++ w/t/t1506-rev-parse-diagnosis.sh\n@@ -140,12 +140,13 @@ test_expect_success 'incorrect file in :path and :N:path' '\n '\n \n test_expect_success 'invalid @{n} reference' '\n+\t: git commit --allow-empty -m 'void' &&\n \ttest_must_fail git rev-parse main@{99999} >output 2>error &&\n \ttest_must_be_empty output &&\n-\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\n+\ttest_grep \"log for [^ ]* only has [1-9][0-9]* entr\" error &&\n \ttest_must_fail git rev-parse --verify main@{99999} >output 2>error &&\n \ttest_must_be_empty output &&\n-\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n+\ttest_grep \"log for [^ ]* only has [1-9][0-9]* entr\" error\n '\n \n test_expect_success 'relative path not found' '\n\n"},{"id":"556200","messageId":"20261025061222.382-1-aniketgupta3001@gmail.com","threadId":"66643","inReplyTo":"20261023133118.456-1-aniketgupta3001@gmail.com","subject":"[GSoC PATCH v2] object-name: use Q_() for the reflog entry count","fromName":"Aniket Gupta","fromEmail":"aniketgupta3001@gmail.com","sentAt":"2026-10-25T06:12:22Z","receivedAt":"2026-10-25T06:12:22Z","isPatch":true,"sender":{"key":"aniketgupta3001@gmail.com","avatar":null},"body":"When reflog is asked for an entry that it doesnt have, for eg with\n\"HEAD@{5}\" get_oid_basic() reports how many entries the log has. The\nmessage is not marked for plural forms and a log with one entry says\nthat \"only has 1 entries\"\n\nUse Q_() so that the singular is used for one entry so that\ntranslations for languages with other plural forms also can have the\nright form for each count.\n\nSigned-off-by: Aniket Gupta <aniketgupta3001@gmail.com>\n---\nResend of v2, now sent as a reply to v1. No other changes.\n\nChanges since v1: t1506 was also looking for \"entries\" and thus\nfailed with a one-entry reflog. Now it matches \"entr\" just like Junio\nsuggested\n\nv1: https://lore.kernel.org/git/20261023133118.456-1-aniketgupta3001@gmail.com/\n\n object-name.c                  |  4 +++-\n t/t1400-update-ref.sh          | 14 ++++++++++++++\n t/t1506-rev-parse-diagnosis.sh |  4 ++--\n 3 files changed, 19 insertions(+), 3 deletions(-)\n\ndiff --git a/object-name.c b/object-name.c\nindex 654668576..eeaac2ddc 100644\n--- a/object-name.c\n+++ b/object-name.c\n@@ -810,7 +810,9 @@ static int get_oid_basic(struct repository *r, const char *str, int len,\n \t\t\t\tif (flags & GET_OID_QUIETLY) {\n \t\t\t\t\texit(128);\n \t\t\t\t}\n-\t\t\t\tdie(_(\"log for '%.*s' only has %d entries\"),\n+\t\t\t\tdie(Q_(\"log for '%.*s' only has %d entry\",\n+\t\t\t\t       \"log for '%.*s' only has %d entries\",\n+\t\t\t\t       co_cnt),\n \t\t\t\t    len, str, co_cnt);\n \t\t\t}\n \t\t\tif (flags & GET_OID_GENTLY) {\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex 1a164c96f..1d1b46379 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -458,6 +458,20 @@ test_expect_success 'query reflog with gap' '\n \ttest_grep -F \"warning: log for ref $m has gap after $gd\" stderr\n '\n \n+test_expect_success 'reflog entry out of range reports how many there are' '\n+\ttest_when_finished \"git update-ref -d $m\" &&\n+\n+\tGIT_COMMITTER_DATE=\"1117150320 -0500\" git update-ref $m $A &&\n+\ttest_must_fail git rev-parse --verify \"main@{5}\" 2>actual &&\n+\techo \"fatal: log for ${SQ}main${SQ} only has 1 entry\" >expect &&\n+\ttest_cmp expect actual &&\n+\n+\tGIT_COMMITTER_DATE=\"1117150380 -0500\" git update-ref $m $B &&\n+\ttest_must_fail git rev-parse --verify \"main@{5}\" 2>actual &&\n+\techo \"fatal: log for ${SQ}main${SQ} only has 2 entries\" >expect &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'creating initial files' '\n \ttest_when_finished rm -f M &&\n \techo TEST >F &&\ndiff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh\nindex 722884e65..9a4b93b79 100755\n--- a/t/t1506-rev-parse-diagnosis.sh\n+++ b/t/t1506-rev-parse-diagnosis.sh\n@@ -142,10 +142,10 @@ test_expect_success 'incorrect file in :path and :N:path' '\n test_expect_success 'invalid @{n} reference' '\n \ttest_must_fail git rev-parse main@{99999} >output 2>error &&\n \ttest_must_be_empty output &&\n-\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error  &&\n+\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entr\" error &&\n \ttest_must_fail git rev-parse --verify main@{99999} >output 2>error &&\n \ttest_must_be_empty output &&\n-\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entries\" error\n+\ttest_grep \"log for [^ ]* only has [0-9][0-9]* entr\" error\n '\n \n test_expect_success 'relative path not found' '\n-- \n2.43.0\n\n\n"}]}