remote: use plural-only message for diverged branch status
PATCH 1/1 remote: use plural-only message for diverged branch status
From: Harald Nordgren <[email protected]>
Drop Q_() singular form and use _() with the plural string only.
---
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(-)
remote.c +2 -7
@@ -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
Signature · 1 line
gitgitgadget
Re: [PATCH] checkout: add --autostash option for branch switching
Quoted 41 lines
Quoted 32 lines
Harald Nordgren (2):
refactorformat_branch_comparisonin preparation
status: show comparison with push remote tracking branchremote.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/2138Range-diff vs v19:
1:
451d7a4986! 1:bb3e00863brefactorformat_branch_comparisonin 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, "Quoted 8 lines
+- "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))
Quoted 4 lines
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/[email protected]/
Harald
Quoted 3 lines · Harald Nordgren via GitGitGadget
From: Harald Nordgren <[email protected]>
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.
Quoted 33 lines
Signed-off-by Harald Nordgren <[email protected]>---
format_branch_comparison: diverged message has only plural casePublished-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/2239remote.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)remote.c +2
-7@@ -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
Quoted 13 lines · Junio C Hamano
Quoted 3 lines · Harald Nordgren via GitGitGadget
From: Harald Nordgren <[email protected]>
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.
Quoted 4 lines
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.
Thanks.
Quoted 8 lines · Junio C Hamano
remote: don't use
Q_()when it is not neededIn 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
Quoted 4 lines · Phillip Wood
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]
Quoted 8 lines
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.
Quoted 15 lines · Junio C Hamano
Quoted 4 lines · Phillip Wood
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]
Quoted 8 lines
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.
Quoted 6 lines
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
Quoted 15 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.
Quoted 19 lines · Phillip Wood
Quoted 18 lines · Junio C Hamano
Quoted 4 lines · Phillip Wood
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]
Quoted 8 lines
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.
Quoted 6 lines
Quoted 3 lines
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.
Quoted 20 lines
Thanks
Phillip
Quoted 15 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.
Quoted 10 lines · Junio C Hamano
Quoted 6 lines · Phillip Wood
Quoted 3 lines
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.
Quoted 7 lines
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