diff-parseopt: convert --ws-error-highlight
Mark one more string for translation while at there. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Mar 24, 2019 at 15:19 UTC
5a749d9f97c680c7379cadda474396e7c4301254
1 file changed
+12
-10
diff.c
+12
-10
@@ -4801,17 +4801,18 @@ static void enable_patch_output(int *fmt)
4801
*fmt |= DIFF_FORMAT_PATCH;
4802
}
4803
4804
-static int parse_ws_error_highlight_opt(struct diff_options *opt, const char *arg)
4804
+static int diff_opt_ws_error_highlight(const struct option *option,
4805
+ const char *arg, int unset)
4806
{
4807
+ struct diff_options *opt = option->value;
4808
int val = parse_ws_error_highlight(arg);
4809
4808
- if (val < 0) {
4809
- error("unknown value after ws-error-highlight=%.*s",
4810
- -1 - val, arg);
4811
- return 0;
4812
- }
4810
+ BUG_ON_OPT_NEG(unset);
4811
+ if (val < 0)
4812
+ return error(_("unknown value after ws-error-highlight=%.*s"),
4813
+ -1 - val, arg);
4814
opt->ws_error_highlight = val;
4814
- return 1;
4815
+ return 0;
4816
}
4817
4818
static int parse_objfind_opt(struct diff_options *opt, const char *arg)
@@ -5234,6 +5235,9 @@ static void prep_parse_options(struct diff_options *options)
5235
N_("show full pre- and post-image object names on the \"index\" lines")),
5236
OPT_COLOR_FLAG(0, "color", &options->use_color,
5237
N_("show colored diff")),
5238
+ OPT_CALLBACK_F(0, "ws-error-highlight", options, N_("<kind>"),
5239
+ N_("highlight whitespace errors in the 'context', 'old' or 'new' lines in the diff"),
5240
+ PARSE_OPT_NONEG, diff_opt_ws_error_highlight),
5241
OPT_CALLBACK_F(0, "output-indicator-new",
5242
&options->output_indicators[OUTPUT_INDICATOR_NEW],
5243
N_("<char>"),
@@ -5397,9 +5401,7 @@ int diff_opt_parse(struct diff_options *options,
5401
if (cm & COLOR_MOVED_WS_ERROR)
5402
return -1;
5403
options->color_moved_ws_handling = cm;
5400
- } else if (skip_prefix(arg, "--ws-error-highlight=", &arg))
5401
- return parse_ws_error_highlight_opt(options, arg);
5402
- else if (!strcmp(arg, "--ita-invisible-in-index"))
5404
+ } else if (!strcmp(arg, "--ita-invisible-in-index"))
5405
options->ita_invisible_in_index = 1;
5406
else if (!strcmp(arg, "--ita-visible-in-index"))
5407
options->ita_invisible_in_index = 0;