Skip to content

Commit 078fe30

Browse files
jnavilagitster
authored andcommitted
i18n: simplify numeric error reporting
Signed-off-by: Jean-Noel Avila <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8aa6dc1 commit 078fe30

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

config.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -652,46 +652,34 @@ int git_parse_ulong(const char *value, unsigned long *ret)
652652
NORETURN
653653
static void die_bad_number(const char *name, const char *value)
654654
{
655+
const char * error_type = (errno == ERANGE)? _("out of range"):_("invalid unit");
656+
655657
if (!value)
656658
value = "";
657659

658660
if (!(cf && cf->name))
659-
die(errno == ERANGE
660-
? _("bad numeric config value '%s' for '%s': out of range")
661-
: _("bad numeric config value '%s' for '%s': invalid unit"),
662-
value, name);
661+
die(_("bad numeric config value '%s' for '%s': %s"),
662+
value, name, error_type);
663663

664664
switch (cf->origin_type) {
665665
case CONFIG_ORIGIN_BLOB:
666-
die(errno == ERANGE
667-
? _("bad numeric config value '%s' for '%s' in blob %s: out of range")
668-
: _("bad numeric config value '%s' for '%s' in blob %s: invalid unit"),
669-
value, name, cf->name);
666+
die(_("bad numeric config value '%s' for '%s' in blob %s: %s"),
667+
value, name, cf->name, error_type);
670668
case CONFIG_ORIGIN_FILE:
671-
die(errno == ERANGE
672-
? _("bad numeric config value '%s' for '%s' in file %s: out of range")
673-
: _("bad numeric config value '%s' for '%s' in file %s: invalid unit"),
674-
value, name, cf->name);
669+
die(_("bad numeric config value '%s' for '%s' in file %s: %s"),
670+
value, name, cf->name, error_type);
675671
case CONFIG_ORIGIN_STDIN:
676-
die(errno == ERANGE
677-
? _("bad numeric config value '%s' for '%s' in standard input: out of range")
678-
: _("bad numeric config value '%s' for '%s' in standard input: invalid unit"),
679-
value, name);
672+
die(_("bad numeric config value '%s' for '%s' in standard input: %s"),
673+
value, name, error_type);
680674
case CONFIG_ORIGIN_SUBMODULE_BLOB:
681-
die(errno == ERANGE
682-
? _("bad numeric config value '%s' for '%s' in submodule-blob %s: out of range")
683-
: _("bad numeric config value '%s' for '%s' in submodule-blob %s: invalid unit"),
684-
value, name, cf->name);
675+
die(_("bad numeric config value '%s' for '%s' in submodule-blob %s: %s"),
676+
value, name, cf->name, error_type);
685677
case CONFIG_ORIGIN_CMDLINE:
686-
die(errno == ERANGE
687-
? _("bad numeric config value '%s' for '%s' in command line %s: out of range")
688-
: _("bad numeric config value '%s' for '%s' in command line %s: invalid unit"),
689-
value, name, cf->name);
678+
die(_("bad numeric config value '%s' for '%s' in command line %s: %s"),
679+
value, name, cf->name, error_type);
690680
default:
691-
die(errno == ERANGE
692-
? _("bad numeric config value '%s' for '%s' in %s: out of range")
693-
: _("bad numeric config value '%s' for '%s' in %s: invalid unit"),
694-
value, name, cf->name);
681+
die(_("bad numeric config value '%s' for '%s' in %s: %s"),
682+
value, name, cf->name, error_type);
695683
}
696684
}
697685

0 commit comments

Comments
 (0)