Skip to contentSkip to conversation

bug: incorrect plurality of "commit" in git status

PATCH In review Alfonsogonzalez, Ernesto (GE Digital) 4 participants 8 messages Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

[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"

#1 lore raw

PATCH 1/1 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.

---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
remote.c +1 -1
index 28fd676..212426e 100644
@@ -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,
Signature · 1 line
2.8.0.rc0.210.gd302cd2
#2 lore raw

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

Quoted 17 lines · Nguyễn Thái Ngọc Duy

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.

---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
remote.c +0 -0
index 28fd676..212426e 100644

remote.c int format_tracking_info(struct branch *branch, struct strbuf *sb) · line 2111

Quoted 5 lines
remote.c +1 -1
@@ -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?

Quoted 10 lines
remote.c +0 -1
                        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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

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

Quoted 26 lines · Stefan Beller
Quoted 17 lines · Nguyễn Thái Ngọc Duy

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.

---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
remote.c +0 -0
index 28fd676..212426e 100644

remote.c int format_tracking_info(struct branch *branch, struct strbuf *sb) · line 2111

Quoted 5 lines
remote.c +1 -1
@@ -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)

Quoted 4 lines

"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.

Signature · 1 line
Duy
#4 lore raw

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

Quoted 11 lines · Duy Nguyen
Quoted 6 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

#5 lore raw

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

Quoted 6 lines · Jeff King

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

Signature · 1 line
Duy
#6 lore raw

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

Quoted 11 lines · Duy Nguyen
Quoted 6 lines · Jeff King

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

#7 lore raw

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

Quoted 14 lines · Jeff King
Quoted 11 lines · Duy Nguyen
Quoted 6 lines · Jeff King

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_().

Quoted 7 lines

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)

Signature · 1 line
Duy