threads / bug / 42205

bug: incorrect plurality of "commit" in git status

Subject: bug: incorrect plurality of "commit" in git status

## tl;dr

8 messages between May 2, 2016 and May 3, 2016.

replies: 7people: 4as markdown or json

Nguyễn Thái Ngọc Duy· May 3, 2016, 00:12 UTC · re: Alfonsogonzalez, Ernesto (GE Digital) · lore

[PATCH] remote.c: specify correct plural form in "commit diverge" message

We need to count both "ours" and "theirs" commits when selecting plural form for this message. Note that even though in this block, both ours and theirs must be positive (i.e. can't be in singular form), we still keep Q_(singular, plural) because languages other than English may have more than one plural form.

Reported-by: Alfonsogonzalez, Ernesto (GE Digital) <ernesto.alfonsogonzalez@ge.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/remote.c b/remote.c
index 28fd676..212426e 100644
--- a/remote.c
+++ b/remote.c
@@ -2108,7 +2108,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
 			   "Your branch and '%s' have diverged,\n"
 			       "and have %d and %d different commits each, "
 			       "respectively.\n",
-			   theirs),
+			   ours + theirs),
 			base, ours, theirs);
 		if (advice_status_hints)
 			strbuf_addf(sb,
-- 
2.8.0.rc0.210.gd302cd2
Stefan Beller· May 3, 2016, 00:16 UTC · re: Nguyễn Thái Ngọc Duy · lore

Re: [PATCH] remote.c: specify correct plural form in "commit diverge" message

On Mon, May 2, 2016 at 5:12 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 22 quoted lines
> We need to count both "ours" and "theirs" commits when selecting plural
> form for this message. Note that even though in this block, both ours
> and theirs must be positive (i.e. can't be in singular form), we still
> keep Q_(singular, plural) because languages other than English may have
> more than one plural form.
>
> Reported-by: Alfonsogonzalez, Ernesto (GE Digital) <ernesto.alfonsogonzalez@ge.com>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  remote.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/remote.c b/remote.c
> index 28fd676..212426e 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -2108,7 +2108,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
>                            "Your branch and '%s' have diverged,\n"
>                                "and have %d and %d different commits each, "
>                                "respectively.\n",
> -                          theirs),
> +                          ours + theirs),
I think it needs to be max(ours, theirs)
    "Your branch and '%s' have diverged,\n"
    "and have 1 and 1 different commit each, "
so singular for that too, no?
Show 10 quoted lines
>                         base, ours, theirs);
>                 if (advice_status_hints)
>                         strbuf_addf(sb,
> --
> 2.8.0.rc0.210.gd302cd2
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Duy Nguyen· May 3, 2016, 00:20 UTC · re: Stefan Beller · lore

Re: [PATCH] remote.c: specify correct plural form in "commit diverge" message

On Tue, May 3, 2016 at 7:16 AM, Stefan Beller <sbeller@google.com> wrote:
Show 30 quoted lines
> On Mon, May 2, 2016 at 5:12 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> We need to count both "ours" and "theirs" commits when selecting plural
>> form for this message. Note that even though in this block, both ours
>> and theirs must be positive (i.e. can't be in singular form), we still
>> keep Q_(singular, plural) because languages other than English may have
>> more than one plural form.
>>
>> Reported-by: Alfonsogonzalez, Ernesto (GE Digital) <ernesto.alfonsogonzalez@ge.com>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>>  remote.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/remote.c b/remote.c
>> index 28fd676..212426e 100644
>> --- a/remote.c
>> +++ b/remote.c
>> @@ -2108,7 +2108,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
>>                            "Your branch and '%s' have diverged,\n"
>>                                "and have %d and %d different commits each, "
>>                                "respectively.\n",
>> -                          theirs),
>> +                          ours + theirs),
>
> I think it needs to be max(ours, theirs)
>
>     "Your branch and '%s' have diverged,\n"
>     "and have 1 and 1 different commit each, "
>
> so singular for that too, no?

I thought that would be "1 and 1 commits". English is complicated :-D I don't think Q_() is prepared to deal with this, other languages may have different interpretation of "x and y" too. But we can at least make the English version right.

-- 
Duy
Jeff King· May 3, 2016, 04:20 UTC · re: Duy Nguyen · lore

Re: [PATCH] remote.c: specify correct plural form in "commit diverge" message

On Tue, May 03, 2016 at 07:20:27AM +0700, Duy Nguyen wrote:
Show 11 quoted lines
> > I think it needs to be max(ours, theirs)
> >
> >     "Your branch and '%s' have diverged,\n"
> >     "and have 1 and 1 different commit each, "
> >
> > so singular for that too, no?
> 
> I thought that would be "1 and 1 commits". English is complicated :-D
> I don't think Q_() is prepared to deal with this, other languages may
> have different interpretation of "x and y" too. But we can at least
> make the English version right.

Yes, it should still be "1 and 1 commits", I think. An actual human would probably say something like "and each has %d commit(s)" when the two values are the same, though.

Note that I do not think the singular case can ever trigger with your new code. We know that both "ours" and "theirs" are non-zero to get to this message, which means "ours + theirs" must be at least 2 (barring negative commit counts, of course :) ).

So you could probably replace the Q_() with just a _().
-Peff
Duy Nguyen· May 3, 2016, 04:43 UTC · re: Jeff King · lore

Re: [PATCH] remote.c: specify correct plural form in "commit diverge" message

On Tue, May 3, 2016 at 11:20 AM, Jeff King <peff@peff.net> wrote:
Show 6 quoted lines
> Note that I do not think the singular case can ever trigger with your
> new code. We know that both "ours" and "theirs" are non-zero to get to
> this message, which means "ours + theirs" must be at least 2 (barring
> negative commit counts, of course :) ).
>
> So you could probably replace the Q_() with just a _().

Problem is there are languages with more than one plural form (and the winner is Arabic with six(!) forms [1]). So even if singular form is never used, I think we still should stick to Q_().

[1] https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
-- 
Duy
Jeff King· May 3, 2016, 04:48 UTC · re: Duy Nguyen · lore

Re: [PATCH] remote.c: specify correct plural form in "commit diverge" message

On Tue, May 03, 2016 at 11:43:41AM +0700, Duy Nguyen wrote:
Show 11 quoted lines
> On Tue, May 3, 2016 at 11:20 AM, Jeff King <peff@peff.net> wrote:
> > Note that I do not think the singular case can ever trigger with your
> > new code. We know that both "ours" and "theirs" are non-zero to get to
> > this message, which means "ours + theirs" must be at least 2 (barring
> > negative commit counts, of course :) ).
> >
> > So you could probably replace the Q_() with just a _().
> 
> Problem is there are languages with more than one plural form (and the
> winner is Arabic with six(!) forms [1]). So even if singular form is
> never used, I think we still should stick to Q_().

Neat, I didn't know Q_() could handle that (I guess you are stuck specifying only the two cases in the untranslated form, but the PO files can do magic in the backend).

It would be nice if there were some way to mark it as "this string will never be shown", or "will always be >= 2" as a hint for translators. I guess those can go in a specially-formatted comment.

-Peff
Duy Nguyen· May 3, 2016, 09:32 UTC · re: Jeff King · lore

Re: [PATCH] remote.c: specify correct plural form in "commit diverge" message

On Tue, May 3, 2016 at 11:48 AM, Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> On Tue, May 03, 2016 at 11:43:41AM +0700, Duy Nguyen wrote:
>
>> On Tue, May 3, 2016 at 11:20 AM, Jeff King <peff@peff.net> wrote:
>> > Note that I do not think the singular case can ever trigger with your
>> > new code. We know that both "ours" and "theirs" are non-zero to get to
>> > this message, which means "ours + theirs" must be at least 2 (barring
>> > negative commit counts, of course :) ).
>> >
>> > So you could probably replace the Q_() with just a _().
>>
>> Problem is there are languages with more than one plural form (and the
>> winner is Arabic with six(!) forms [1]). So even if singular form is
>> never used, I think we still should stick to Q_().
>
> Neat, I didn't know Q_() could handle that (I guess you are stuck
> specifying only the two cases in the untranslated form, but the PO files
> can do magic in the backend).
>
> It would be nice if there were some way to mark it as "this string will
> never be shown", or "will always be >= 2" as a hint for translators. I
> guess those can go in a specially-formatted comment.

Yep, that's the only way I know. But it's probably not good for this purpose. Imagine if the code is moved around a bit and this exact string can take n == 1 (probably not given the "x _and_ y commits" pattern) then we need to tell all translators (optional hints are not enough) to translate the "n < 2" part or empty string can be printed. And at least in _() case, empty string is an indication of untranslated messages, the translator would just translate anyway so he/she can identify new messages easier.

On the practical side, since this string has been here for a long time, it's been already translated in all supported languages (except it.po), hinting now won't help much (besides it.po)

-- 
Duy

← back to recent threads