Volume XXII, number 280Wednesday, October 7, 2026Latest message 53 minutes ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

patchremote: use plural-only message for diverged branch status

9 messages between Mar 14, 2026 and Mar 25, 2026, from Harald Nordgren via GitGitGadget, Harald Nordgren, Junio C Hamano, Phillip Wood, Kaartic Sivaraam.

Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.

Harald Nordgren via GitGitGadgetMar 14, 2026, 09:12 UTC on lore
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(-)
Show changes to remote.c +2 −7
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
Harald NordgrenMar 14, 2026, 09:16 UTC in reply to Harald Nordgren via GitGitGadget on lore

Re: [PATCH] checkout: add --autostash option for branch switching

Show 45 quoted lines
>> 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
Junio C HamanoMar 14, 2026, 16:52 UTC in reply to Harald Nordgren via GitGitGadget on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

"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.
Show 33 quoted lines
> 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
Junio C HamanoMar 14, 2026, 18:38 UTC in reply to Junio C Hamano on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> "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.
Phillip WoodMar 14, 2026, 20:08 UTC in reply to Junio C Hamano on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

On 14/03/2026 18:38, Junio C Hamano wrote:
Show 8 quoted lines
> 
>      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

Junio C HamanoMar 15, 2026, 02:08 UTC in reply to Phillip Wood on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

Phillip Wood <phillip.wood123@gmail.com> writes:
Show 12 quoted lines
> 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.
Phillip WoodMar 16, 2026, 10:49 UTC in reply to Junio C Hamano on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

On 15/03/2026 02:08, Junio C Hamano wrote:
Show 21 quoted lines
> 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
Show 15 quoted lines
> 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.
Junio C HamanoMar 16, 2026, 17:06 UTC in reply to Phillip Wood on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

Phillip Wood <phillip.wood123@gmail.com> writes:
Show 25 quoted lines
> 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.

Show 20 quoted lines
>
> 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.
Kaartic SivaraamMar 25, 2026, 04:29 UTC in reply to Junio C Hamano on lore

Re: [PATCH] remote: use plural-only message for diverged branch status

On Mon, Mar 16, 2026 at 10:37 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
>
> 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

Back to recent threads