bug: incorrect plurality of "commit" in git status

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

bug: incorrect plurality of "commit" in git status

Alfonsogonzalez, Ernesto (GE Digital)

[debian-vm]$ gt
On branch feat/junit-test
Your branch and 'origin/feat/junit-test' have diverged,
and have 19 and 1 different commit each, respectively.



Should be "commits"--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Duy Nguyen
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) <[hidden email]>
Signed-off-by: Nguyễn Thái Ngọc Duy <[hidden email]>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Stefan Beller-4
On Mon, May 2, 2016 at 5:12 PM, Nguyễn Thái Ngọc Duy <[hidden email]> 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) <[hidden email]>
> Signed-off-by: Nguyễn Thái Ngọc Duy <[hidden email]>
> ---
>  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?


>                         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 [hidden email]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Duy Nguyen
On Tue, May 3, 2016 at 7:16 AM, Stefan Beller <[hidden email]> wrote:

> On Mon, May 2, 2016 at 5:12 PM, Nguyễn Thái Ngọc Duy <[hidden email]> 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) <[hidden email]>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <[hidden email]>
>> ---
>>  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Jeff King
On Tue, May 03, 2016 at 07:20:27AM +0700, Duy Nguyen wrote:

> > 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Duy Nguyen
On Tue, May 3, 2016 at 11:20 AM, Jeff King <[hidden email]> 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_().

[1] https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
--
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Jeff King
On Tue, May 03, 2016 at 11:43:41AM +0700, Duy Nguyen wrote:

> On Tue, May 3, 2016 at 11:20 AM, Jeff King <[hidden email]> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Duy Nguyen
On Tue, May 3, 2016 at 11:48 AM, Jeff King <[hidden email]> wrote:

> On Tue, May 03, 2016 at 11:43:41AM +0700, Duy Nguyen wrote:
>
>> On Tue, May 3, 2016 at 11:20 AM, Jeff King <[hidden email]> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html