config.c: refactor die_bad_number() to not call gettext() early

Prepare die_bad_number() for a change to specially handle GIT_TEST_GETTEXT_POISON calling git_env_bool() by making die_bad_number() not call gettext() early, which would in turn call git_env_bool(). There's no meaningful change here yet, just a re-arrangement of the current code to make that subsequent change easier to read. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 21, 2019 at 12:18 UTC 2e43cd4caa8ad9eb0c53adc1e00dcd027b8710fd
1 file changed +10 -9
config.c
+10 -9
@@ -949,34 +949,35 @@ int git_parse_ssize_t(const char *value, ssize_t *ret)
949 NORETURN
950 static void die_bad_number(const char *name, const char *value)
951 {
952 - const char * error_type = (errno == ERANGE)? _("out of range"):_("invalid unit");
952 + const char *error_type = (errno == ERANGE) ?
953 + N_("out of range") : N_("invalid unit");
954 + const char *bad_numeric = N_("bad numeric config value '%s' for '%s': %s");
955
956 if (!value)
957 value = "";
958
959 if (!(cf && cf->name))
958 - die(_("bad numeric config value '%s' for '%s': %s"),
959 - value, name, error_type);
960 + die(_(bad_numeric), value, name, _(error_type));
961
962 switch (cf->origin_type) {
963 case CONFIG_ORIGIN_BLOB:
964 die(_("bad numeric config value '%s' for '%s' in blob %s: %s"),
964 - value, name, cf->name, error_type);
965 + value, name, cf->name, _(error_type));
966 case CONFIG_ORIGIN_FILE:
967 die(_("bad numeric config value '%s' for '%s' in file %s: %s"),
967 - value, name, cf->name, error_type);
968 + value, name, cf->name, _(error_type));
969 case CONFIG_ORIGIN_STDIN:
970 die(_("bad numeric config value '%s' for '%s' in standard input: %s"),
970 - value, name, error_type);
971 + value, name, _(error_type));
972 case CONFIG_ORIGIN_SUBMODULE_BLOB:
973 die(_("bad numeric config value '%s' for '%s' in submodule-blob %s: %s"),
973 - value, name, cf->name, error_type);
974 + value, name, cf->name, _(error_type));
975 case CONFIG_ORIGIN_CMDLINE:
976 die(_("bad numeric config value '%s' for '%s' in command line %s: %s"),
976 - value, name, cf->name, error_type);
977 + value, name, cf->name, _(error_type));
978 default:
979 die(_("bad numeric config value '%s' for '%s' in %s: %s"),
979 - value, name, cf->name, error_type);
980 + value, name, cf->name, _(error_type));
981 }
982 }
983