Re: [PATCH 3/7] shortlog: extract `--group` fragment for translation
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Oct 11, 2022, 10:55 UTC
- Message-ID
- <221011.867d16pr0n.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <c3f50465cba4430b2014a76c5e473b906db50059.1665448437.git.me@ttaylorr.com>
On Mon, Oct 10 2022, Taylor Blau wrote:
Show 25 quoted lines
> The subsequent commit will add another unhandled case in
> `read_from_stdin()` which will want to use the same message as with
> `--group=trailer`.
>
> Extract the "--group=trailer" part from this message so the same
> translation key can be used for both cases.
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
> builtin/shortlog.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/shortlog.c b/builtin/shortlog.c
> index 53c379a51d..051c97bd5a 100644
> --- a/builtin/shortlog.c
> +++ b/builtin/shortlog.c
> @@ -132,7 +132,7 @@ static void read_from_stdin(struct shortlog *log)
> match = committer_match;
> break;
> case SHORTLOG_GROUP_TRAILER:
> - die(_("using --group=trailer with stdin is not supported"));
> + die(_("using %s with stdin is not supported"), "--group=trailer");
> default:
> BUG("unhandled shortlog group");
> }Rather than add another translation that you can use in 2x places here (with 4/7) instead do:
diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 7a1e1fe7c0e..59aef24f637 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -132,7 +132,8 @@ static void read_from_stdin(struct shortlog *log) match = committer_match; break; case SHORTLOG_GROUP_TRAILER: - die(_("using --group=trailer with stdin is not supported")); + die(_("options '%s' and '%s' cannot be used together"), + "--group=<trailer>", "--stdin"); default: BUG("unhandled shortlog group"); } Which as you can see with "git grep 'cannot be used together'" we already use in a lot of places. We should probably extract this to a: die_opt_2_incompatible("--group=<trailer>", "--stdin"); But that can all be done in some hypothetical future, but for now the status quo is that we know of these common strings, and copy/paste them in various files.