* [PATCH] remote: use plural-only message for diverged branch status
@ 2026-03-14 9:12 Harald Nordgren via GitGitGadget
2026-03-14 9:16 ` [PATCH] checkout: add --autostash option for branch switching Harald Nordgren
2026-03-14 16:52 ` [PATCH] remote: use plural-only message for diverged branch status Junio C Hamano
0 siblings, 2 replies; 9+ messages in thread
From: Harald Nordgren via GitGitGadget @ 2026-03-14 9:12 UTC (permalink / raw)
To: git; +Cc: Harald Nordgren, Harald Nordgren
From: Harald Nordgren <haraldnordgren@gmail.com>
Drop Q_() singular form and use _() with the plural string only.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
---
format_branch_comparison: diverged message has only plural case
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2239%2FHaraldNordgren%2Fformat_branch_comparison__plural-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2239/HaraldNordgren/format_branch_comparison__plural-v1
Pull-Request: https://github.com/git/git/pull/2239
remote.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/remote.c b/remote.c
index 7ca2a6501b..12136dfa23 100644
--- a/remote.c
+++ b/remote.c
@@ -2307,13 +2307,8 @@ static void format_branch_comparison(struct strbuf *sb,
_(" (use \"git pull\" to update your local branch)\n"));
} else {
strbuf_addf(sb,
- Q_("Your branch and '%s' have diverged,\n"
- "and have %d and %d different commit each, "
- "respectively.\n",
- "Your branch and '%s' have diverged,\n"
- "and have %d and %d different commits each, "
- "respectively.\n",
- ours + theirs),
+ _("Your branch and '%s' have diverged,\n"
+ "and have %d and %d different commits each, respectively.\n"),
branch_name, ours, theirs);
if (use_divergence_advice && advice_enabled(ADVICE_STATUS_HINTS))
strbuf_addstr(sb,
base-commit: dc6ecd5354dca88d51b6d6562777fc8fc10d77e1
--
gitgitgadget
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] checkout: add --autostash option for branch switching
2026-03-14 9:12 [PATCH] remote: use plural-only message for diverged branch status Harald Nordgren via GitGitGadget
@ 2026-03-14 9:16 ` Harald Nordgren
2026-03-14 16:52 ` [PATCH] remote: use plural-only message for diverged branch status Junio C Hamano
1 sibling, 0 replies; 9+ messages in thread
From: Harald Nordgren @ 2026-03-14 9:16 UTC (permalink / raw)
To: gitgitgadget; +Cc: git, haraldnordgren
>> Harald Nordgren (2):
>> refactor format_branch_comparison in preparation
>> status: show comparison with push remote tracking branch
>>
>> remote.c | 183 ++++++++++++++++++++-------
>> t/t6040-tracking-info.sh | 262 +++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 403 insertions(+), 42 deletions(-)
>>
>>
>> base-commit: d529f3a197364881746f558e5652f0236131eb86
>> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2138%2FHaraldNordgren%2Fahead_of_main_status-v20
>> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2138/HaraldNordgren/ahead_of_main_status-v20
>> Pull-Request: https://github.com/git/git/pull/2138
>>
>> Range-diff vs v19:
>>
>> 1: 451d7a4986 ! 1: bb3e00863b refactor format_branch_comparison in preparation
>> @@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
>> if (advice_enabled(ADVICE_STATUS_HINTS))
>> strbuf_addstr(sb,
>> _(" (use \"git pull\" to update your local branch)\n"));
>> -@@ remote.c: int format_tracking_info(struct branch *branch, struct strbuf *sb,
>> - "and have %d and %d different commits each, "
>> - "respectively.\n",
>> - ours + theirs),
>> + } else {
>> + strbuf_addf(sb,
>> +- Q_("Your branch and '%s' have diverged,\n"
>> +- "and have %d and %d different commit each, "
>> +- "respectively.\n",
>> +- "Your branch and '%s' have diverged,\n"
>> +- "and have %d and %d different commits each, "
>> +- "respectively.\n",
>> +- ours + theirs),
>> - base, ours, theirs);
>> ++ "Your branch and '%s' have diverged,\n"
>> ++ "and have %d and %d different commits each, respectively.\n",
>> + branch_name, ours, theirs);
>> if (show_divergence_advice &&
>> advice_enabled(ADVICE_STATUS_HINTS))
>
> Could you not mix the ours+theirs thing into the same step? Either
> make it a standalone patch to clean up before or after your main 2
> patches, or leave it totally outside the series and send it after
> this series settles.
Making a change that was left out of https://lore.kernel.org/git/xmqqzf6lqs9w.fsf@gitster.g/
Harald
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-14 9:12 [PATCH] remote: use plural-only message for diverged branch status Harald Nordgren via GitGitGadget
2026-03-14 9:16 ` [PATCH] checkout: add --autostash option for branch switching Harald Nordgren
@ 2026-03-14 16:52 ` Junio C Hamano
2026-03-14 18:38 ` Junio C Hamano
1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2026-03-14 16:52 UTC (permalink / raw)
To: Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> Drop Q_() singular form and use _() with the plural string only.
I know the commit title talks about plural-only, but please make
sure that the body of the log message carries all the necessary
information to justify the change standalone. "In the else clause,
both ours and theirs are positive integers so ours+theirs must be at
least 2, hence there is no need to prepare singular and plural
variants of the message", or something to that effect, perhaps.
The patch text and the reasoning behind it does sound familiar and I
vaguely recall discussing about it ;-)
Thanks.
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
> format_branch_comparison: diverged message has only plural case
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2239%2FHaraldNordgren%2Fformat_branch_comparison__plural-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2239/HaraldNordgren/format_branch_comparison__plural-v1
> Pull-Request: https://github.com/git/git/pull/2239
>
> remote.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/remote.c b/remote.c
> index 7ca2a6501b..12136dfa23 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -2307,13 +2307,8 @@ static void format_branch_comparison(struct strbuf *sb,
> _(" (use \"git pull\" to update your local branch)\n"));
> } else {
> strbuf_addf(sb,
> - Q_("Your branch and '%s' have diverged,\n"
> - "and have %d and %d different commit each, "
> - "respectively.\n",
> - "Your branch and '%s' have diverged,\n"
> - "and have %d and %d different commits each, "
> - "respectively.\n",
> - ours + theirs),
> + _("Your branch and '%s' have diverged,\n"
> + "and have %d and %d different commits each, respectively.\n"),
> branch_name, ours, theirs);
> if (use_divergence_advice && advice_enabled(ADVICE_STATUS_HINTS))
> strbuf_addstr(sb,
>
> base-commit: dc6ecd5354dca88d51b6d6562777fc8fc10d77e1
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-14 16:52 ` [PATCH] remote: use plural-only message for diverged branch status Junio C Hamano
@ 2026-03-14 18:38 ` Junio C Hamano
2026-03-14 20:08 ` Phillip Wood
0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2026-03-14 18:38 UTC (permalink / raw)
To: Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren
Junio C Hamano <gitster@pobox.com> writes:
> "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> From: Harald Nordgren <haraldnordgren@gmail.com>
>>
>> Drop Q_() singular form and use _() with the plural string only.
>
> I know the commit title talks about plural-only, but please make
> sure that the body of the log message carries all the necessary
> information to justify the change standalone. "In the else clause,
> both ours and theirs are positive integers so ours+theirs must be at
> least 2, hence there is no need to prepare singular and plural
> variants of the message", or something to that effect, perhaps.
>
> The patch text and the reasoning behind it does sound familiar and I
> vaguely recall discussing about it ;-)
>
> Thanks.
I queued the patch, tentatively with this rewritten message:
remote: don't use Q_() when it is not needed
In this code path, both ours and theirs are already known to be
positive integers, so ours + theirs will always be plural, never
using the first variant given to Q_().
Just use _() with the plural string only.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-14 18:38 ` Junio C Hamano
@ 2026-03-14 20:08 ` Phillip Wood
2026-03-15 2:08 ` Junio C Hamano
0 siblings, 1 reply; 9+ messages in thread
From: Phillip Wood @ 2026-03-14 20:08 UTC (permalink / raw)
To: Junio C Hamano, Harald Nordgren via GitGitGadget; +Cc: git, Harald Nordgren
On 14/03/2026 18:38, Junio C Hamano wrote:
>
> remote: don't use Q_() when it is not needed
>
> In this code path, both ours and theirs are already known to be
> positive integers, so ours + theirs will always be plural, never
> using the first variant given to Q_().
>
> Just use _() with the plural string only.
There can be more than one form of the plural string though. The gettext
manual has the following example of the Polish translation of "file" for
different numbers of files [1]
1 plik
2,3,4 pliki
5-21 plików
22-24 pliki
25-31 plików
ngettext() handles that correctly, translating a single string without
an associated count will not.
Thanks
Phillip
[1]
https://www.gnu.org/software/gettext/manual/gettext.html#Additional-functions-for-plural-forms
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-14 20:08 ` Phillip Wood
@ 2026-03-15 2:08 ` Junio C Hamano
2026-03-16 10:49 ` Phillip Wood
0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2026-03-15 2:08 UTC (permalink / raw)
To: Phillip Wood; +Cc: Harald Nordgren via GitGitGadget, git, Harald Nordgren
Phillip Wood <phillip.wood123@gmail.com> writes:
> There can be more than one form of the plural string though. The gettext
> manual has the following example of the Polish translation of "file" for
> different numbers of files [1]
>
> 1 plik
> 2,3,4 pliki
> 5-21 plików
> 22-24 pliki
> 25-31 plików
>
> ngettext() handles that correctly, translating a single string without
> an associated count will not.
That is a very interesting example, and a valid reason to have me
retract the #leftoverbits that led to the patch being discussed.
But wouldn't that lead to an awkward conclusion, i.e., hits from
"git grep '[^Q]_("[^"]*%[id]' \*.c" are potential bugs that need to
be updated to use ngettext().
Of course, we need to exclude messages like "the error code %d was
returned" and "you have a bug on line %d", but there seem to be real
errors in randomly selected hits from the "git grep" output, e.g.,
add-patch.c: _("Split into %d hunks."),
archive-zip.c: return error(_("path too long (%d chars, SHA1: %s): %s"),
builtin/checkout.c: die(_("'%s' matched multiple (%d) remote tracking branches"),
builtin/credential-store.c: die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
builtin/describe.c: _("found %i tags; gave up search at %s\n"),
builtin/fsck.c: fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max);
You can notice that I started from 'a' and stopped very early in 'b'
;-).
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-15 2:08 ` Junio C Hamano
@ 2026-03-16 10:49 ` Phillip Wood
2026-03-16 17:06 ` Junio C Hamano
0 siblings, 1 reply; 9+ messages in thread
From: Phillip Wood @ 2026-03-16 10:49 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Harald Nordgren via GitGitGadget, git, Harald Nordgren
On 15/03/2026 02:08, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
>> There can be more than one form of the plural string though. The gettext
>> manual has the following example of the Polish translation of "file" for
>> different numbers of files [1]
>>
>> 1 plik
>> 2,3,4 pliki
>> 5-21 plików
>> 22-24 pliki
>> 25-31 plików
>>
>> ngettext() handles that correctly, translating a single string without
>> an associated count will not.
>
> That is a very interesting example, and a valid reason to have me
> retract the #leftoverbits that led to the patch being discussed.
>
> But wouldn't that lead to an awkward conclusion, i.e., hits from
> "git grep '[^Q]_("[^"]*%[id]' \*.c" are potential bugs that need to
> be updated to use ngettext().
I think it does - maybe we should suggest fixing these as a miroproject
for GSoC and Outreachy? It certainly looks like there are plenty of them.
Thanks
Phillip
> Of course, we need to exclude messages like "the error code %d was
> returned" and "you have a bug on line %d", but there seem to be real
> errors in randomly selected hits from the "git grep" output, e.g.,
>
> add-patch.c: _("Split into %d hunks."),
> archive-zip.c: return error(_("path too long (%d chars, SHA1: %s): %s"),
> builtin/checkout.c: die(_("'%s' matched multiple (%d) remote tracking branches"),
> builtin/credential-store.c: die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
> builtin/describe.c: _("found %i tags; gave up search at %s\n"),
> builtin/fsck.c: fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max);
>
> You can notice that I started from 'a' and stopped very early in 'b'
> ;-).
>
> Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-16 10:49 ` Phillip Wood
@ 2026-03-16 17:06 ` Junio C Hamano
2026-03-25 4:29 ` Kaartic Sivaraam
0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2026-03-16 17:06 UTC (permalink / raw)
To: Phillip Wood; +Cc: Harald Nordgren via GitGitGadget, git, Harald Nordgren
Phillip Wood <phillip.wood123@gmail.com> writes:
> On 15/03/2026 02:08, Junio C Hamano wrote:
>> Phillip Wood <phillip.wood123@gmail.com> writes:
>>
>>> There can be more than one form of the plural string though. The gettext
>>> manual has the following example of the Polish translation of "file" for
>>> different numbers of files [1]
>>>
>>> 1 plik
>>> 2,3,4 pliki
>>> 5-21 plików
>>> 22-24 pliki
>>> 25-31 plików
>>>
>>> ngettext() handles that correctly, translating a single string without
>>> an associated count will not.
>>
>> That is a very interesting example, and a valid reason to have me
>> retract the #leftoverbits that led to the patch being discussed.
>>
>> But wouldn't that lead to an awkward conclusion, i.e., hits from
>> "git grep '[^Q]_("[^"]*%[id]' \*.c" are potential bugs that need to
>> be updated to use ngettext().
>
> I think it does - maybe we should suggest fixing these as a miroproject
> for GSoC and Outreachy? It certainly looks like there are plenty of them.
That would be great. It needs a bit of thinking, the required
change for each of them is quite small, and there are tons of them.
An ideal candidate for a microproject.
Adding it to the list of microproject ideas is a good #leftoverbits
as well.
>
> Thanks
>
> Phillip
>
>> Of course, we need to exclude messages like "the error code %d was
>> returned" and "you have a bug on line %d", but there seem to be real
>> errors in randomly selected hits from the "git grep" output, e.g.,
>>
>> add-patch.c: _("Split into %d hunks."),
>> archive-zip.c: return error(_("path too long (%d chars, SHA1: %s): %s"),
>> builtin/checkout.c: die(_("'%s' matched multiple (%d) remote tracking branches"),
>> builtin/credential-store.c: die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
>> builtin/describe.c: _("found %i tags; gave up search at %s\n"),
>> builtin/fsck.c: fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max);
>>
>> You can notice that I started from 'a' and stopped very early in 'b'
>> ;-).
>>
>> Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] remote: use plural-only message for diverged branch status
2026-03-16 17:06 ` Junio C Hamano
@ 2026-03-25 4:29 ` Kaartic Sivaraam
0 siblings, 0 replies; 9+ messages in thread
From: Kaartic Sivaraam @ 2026-03-25 4:29 UTC (permalink / raw)
To: Junio C Hamano
Cc: Phillip Wood, Harald Nordgren via GitGitGadget, git,
Harald Nordgren
On Mon, Mar 16, 2026 at 10:37 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
> >> But wouldn't that lead to an awkward conclusion, i.e., hits from
> >> "git grep '[^Q]_("[^"]*%[id]' \*.c" are potential bugs that need to
> >> be updated to use ngettext().
> >
> > I think it does - maybe we should suggest fixing these as a miroproject
> > for GSoC and Outreachy? It certainly looks like there are plenty of them.
>
> That would be great. It needs a bit of thinking, the required
> change for each of them is quite small, and there are tons of them.
> An ideal candidate for a microproject.
>
> Adding it to the list of microproject ideas is a good #leftoverbits
> as well.
>
This has been added to the microprojects list now. Do check and
let us know in case it needs any tweaks.
https://git.github.io/SoC-2026-Microprojects#fix-improper-pluralization-to-use-ngettext
Thanks.
--
Sivaraam
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-03-25 4:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14 9:12 [PATCH] remote: use plural-only message for diverged branch status Harald Nordgren via GitGitGadget
2026-03-14 9:16 ` [PATCH] checkout: add --autostash option for branch switching Harald Nordgren
2026-03-14 16:52 ` [PATCH] remote: use plural-only message for diverged branch status Junio C Hamano
2026-03-14 18:38 ` Junio C Hamano
2026-03-14 20:08 ` Phillip Wood
2026-03-15 2:08 ` Junio C Hamano
2026-03-16 10:49 ` Phillip Wood
2026-03-16 17:06 ` Junio C Hamano
2026-03-25 4:29 ` Kaartic Sivaraam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox