i18n: i18n: diff: mark die messages for translation

While marking individual messages for translation, consolidate some messages "option 'foo' requires a value" that is used for many options into one by introducing a helper function to die with the message with the option name embedded in it, and ask the translators to localize that single message instead. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt> Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jean-Noël AVILA committed Sep 20, 2016 at 21:04 UTC a2f05c94545a5409d4a90fcad5d495d3d758b218
1 file changed +10 -5
diff.c
+10 -5
@@ -54,6 +54,11 @@ static char diff_colors[][COLOR_MAXLEN] = {
54 GIT_COLOR_NORMAL, /* FUNCINFO */
55 };
56
57 +static NORETURN void die_want_option(const char *option_name)
58 +{
59 + die(_("option '%s' requires a value"), option_name);
60 +}
61 +
62 static int parse_diff_color_slot(const char *var)
63 {
64 if (!strcasecmp(var, "context") || !strcasecmp(var, "plain"))
@@ -3322,7 +3327,7 @@ void diff_setup_done(struct diff_options *options)
3327 if (options->output_format & DIFF_FORMAT_NO_OUTPUT)
3328 count++;
3329 if (count > 1)
3325 - die("--name-only, --name-status, --check and -s are mutually exclusive");
3330 + die(_("--name-only, --name-status, --check and -s are mutually exclusive"));
3331
3332 /*
3333 * Most of the time we can say "there are changes"
@@ -3518,7 +3523,7 @@ static int stat_opt(struct diff_options *options, const char **av)
3523 if (*arg == '=')
3524 width = strtoul(arg + 1, &end, 10);
3525 else if (!*arg && !av[1])
3521 - die("Option '--stat-width' requires a value");
3526 + die_want_option("--stat-width");
3527 else if (!*arg) {
3528 width = strtoul(av[1], &end, 10);
3529 argcount = 2;
@@ -3527,7 +3532,7 @@ static int stat_opt(struct diff_options *options, const char **av)
3532 if (*arg == '=')
3533 name_width = strtoul(arg + 1, &end, 10);
3534 else if (!*arg && !av[1])
3530 - die("Option '--stat-name-width' requires a value");
3535 + die_want_option("--stat-name-width");
3536 else if (!*arg) {
3537 name_width = strtoul(av[1], &end, 10);
3538 argcount = 2;
@@ -3536,7 +3541,7 @@ static int stat_opt(struct diff_options *options, const char **av)
3541 if (*arg == '=')
3542 graph_width = strtoul(arg + 1, &end, 10);
3543 else if (!*arg && !av[1])
3539 - die("Option '--stat-graph-width' requires a value");
3544 + die_want_option("--stat-graph-width");
3545 else if (!*arg) {
3546 graph_width = strtoul(av[1], &end, 10);
3547 argcount = 2;
@@ -3545,7 +3550,7 @@ static int stat_opt(struct diff_options *options, const char **av)
3550 if (*arg == '=')
3551 count = strtoul(arg + 1, &end, 10);
3552 else if (!*arg && !av[1])
3548 - die("Option '--stat-count' requires a value");
3553 + die_want_option("--stat-count");
3554 else if (!*arg) {
3555 count = strtoul(av[1], &end, 10);
3556 argcount = 2;