git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 6/6] i18n: factorize "bad argument" messages

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 3, 2022, 14:41 UTC
Message-ID
<220403.86o81ikywa.gmgdl@evledraar.gmail.com>
In-Reply-To
<febe64a8a069dd81523c33a93cfea9553e40c283.1648915853.git.gitgitgadget@gmail.com>
On Sat, Apr 02 2022, Jean-Noël Avila via GitGitGadget wrote:
> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
>
> We also quote the placeholders as they replace constant strings.

I don't think this change is good in that it takes two different cases we cared about distinguishing before, and squashes them into one. I.e.:

Show 9 quoted lines
> +++ b/builtin/bisect--helper.c
> @@ -268,7 +268,7 @@ static int bisect_write(const char *state, const char *rev,
>  	} else if (one_of(state, terms->term_good, "skip", NULL)) {
>  		strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev);
>  	} else {
> -		res = error(_("Bad bisect_write argument: %s"), state);
> +		res = error(_("bad '%s' argument: '%s'"), "bisect_write", state);
>  		goto finish;
>  	}

I think these should all say "bad value provided for '%s' argument: '%s'", or similar, or maybe the terse version is better. Just a suggestion.

Show 11 quoted lines
> diff --git a/builtin/config.c b/builtin/config.c
> index e7b88a9c08d..2ac36e4f641 100644
> --- a/builtin/config.c
> +++ b/builtin/config.c
> @@ -106,7 +106,7 @@ static int option_parse_type(const struct option *opt, const char *arg,
>  		else if (!strcmp(arg, "color"))
>  			new_type = TYPE_COLOR;
>  		else
> -			die(_("unrecognized --type argument, %s"), arg);
> +			die(_("bad '%s' argument: '%s'"), "--type", arg);
>  	}

I thought some of these were introducing logic errors, because we were conflating unrecognized arguments with bad values, but these all seem to actually mean "bad value", not "unknown flag".

Show 11 quoted lines
> diff --git a/grep.c b/grep.c
> index 82eb7da1022..6aabfc58bb3 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -43,7 +43,7 @@ static int parse_pattern_type_arg(const char *opt, const char *arg)
>  		return GREP_PATTERN_TYPE_FIXED;
>  	else if (!strcmp(arg, "perl"))
>  		return GREP_PATTERN_TYPE_PCRE;
> -	die("bad %s argument: %s", opt, arg);
> +	die("bad '%s' argument: '%s'", opt, arg);
>  }
This and many other changes that follow have nothing to do with i18n.

I think it's a worthwhile cleanup to mark some of these for _(), but shouldn't that come first, or at least after?

Previous: Jean-Noël Avila via GitGitGadget
Message 28 of 28 in “More i18n fixes”
  1. 0/7 More i18n fixesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  2. 1/7 i18n: factorize generic failure messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  3. 2/7 sequencer: factor GIT_AUTHOR_* from message stringsBagas Sanjaya via GitGitGadget, Mar 20, 2022
  4. Bagas SanjayaMar 21, 2022
  5. 3/7 i18n: factorize "bad argument" messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  6. 4/7 i18n: factorize "Server does not support foo" messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  7. 5/7 i18n: factorize "foo does not take arguments" messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  8. 7/7 i18n: factorize unrecognized options arguments messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  9. 6/7 i18n: factorize read-cache error messagesJean-Noël Avila via GitGitGadget, Mar 20, 2022
  10. Johannes SixtMar 21, 2022
  11. Ævar Arnfjörð BjarmasonMar 21, 2022
  12. Junio C HamanoMar 21, 2022
  13. Jean-Noël AVILAMar 21, 2022
  14. Jean-Noël AVILAMar 21, 2022
  15. 0/6 More i18n fixesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  16. 1/6 i18n: factorize generic failure messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  17. Bagas SanjayaApr 3, 2022
  18. Ævar Arnfjörð BjarmasonApr 3, 2022
  19. Ævar Arnfjörð BjarmasonApr 3, 2022
  20. 3/6 i18n: factorize server support messages in fetch-packJean-Noël Avila via GitGitGadget, Apr 2, 2022
  21. 2/6 sequencer: factor GIT_AUTHOR_* from message stringsBagas Sanjaya via GitGitGadget, Apr 2, 2022
  22. 5/6 i18n: factorize read-cache error messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  23. Junio C HamanoApr 3, 2022
  24. 4/6 i18n: factorize "foo does not take arguments" messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  25. Ævar Arnfjörð BjarmasonApr 3, 2022
  26. Junio C HamanoApr 3, 2022
  27. 6/6 i18n: factorize "bad argument" messagesJean-Noël Avila via GitGitGadget, Apr 2, 2022
  28. Ævar Arnfjörð BjarmasonApr 3, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.