diff-parseopt: convert --[no-]color-moved

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:20 UTC 59311a9820df1c5f3463d1447458692fdbfef606
1 file changed +25 -13
diff.c
+25 -13
@@ -4841,6 +4841,27 @@ static int diff_opt_char(const struct option *opt,
4841 return 0;
4842 }
4843
4844 +static int diff_opt_color_moved(const struct option *opt,
4845 + const char *arg, int unset)
4846 +{
4847 + struct diff_options *options = opt->value;
4848 +
4849 + if (unset) {
4850 + options->color_moved = COLOR_MOVED_NO;
4851 + } else if (!arg) {
4852 + if (diff_color_moved_default)
4853 + options->color_moved = diff_color_moved_default;
4854 + if (options->color_moved == COLOR_MOVED_NO)
4855 + options->color_moved = COLOR_MOVED_DEFAULT;
4856 + } else {
4857 + int cm = parse_color_moved(arg);
4858 + if (cm < 0)
4859 + return error(_("bad --color-moved argument: %s"), arg);
4860 + options->color_moved = cm;
4861 + }
4862 + return 0;
4863 +}
4864 +
4865 static int diff_opt_color_words(const struct option *opt,
4866 const char *arg, int unset)
4867 {
@@ -5339,6 +5360,9 @@ static void prep_parse_options(struct diff_options *options)
5360 OPT_CALLBACK_F(0, "color-words", options, N_("<regex>"),
5361 N_("equivalent to --word-diff=color --word-diff-regex=<regex>"),
5362 PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_color_words),
5363 + OPT_CALLBACK_F(0, "color-moved", options, N_("<mode>"),
5364 + N_("move lines of code are colored differently"),
5365 + PARSE_OPT_OPTARG, diff_opt_color_moved),
5366
5367 OPT_GROUP(N_("Diff other options")),
5368 OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@ -5422,19 +5446,7 @@ int diff_opt_parse(struct diff_options *options,
5446 return ac;
5447
5448 /* flags options */
5425 - if (!strcmp(arg, "--color-moved")) {
5426 - if (diff_color_moved_default)
5427 - options->color_moved = diff_color_moved_default;
5428 - if (options->color_moved == COLOR_MOVED_NO)
5429 - options->color_moved = COLOR_MOVED_DEFAULT;
5430 - } else if (!strcmp(arg, "--no-color-moved"))
5431 - options->color_moved = COLOR_MOVED_NO;
5432 - else if (skip_prefix(arg, "--color-moved=", &arg)) {
5433 - int cm = parse_color_moved(arg);
5434 - if (cm < 0)
5435 - return error("bad --color-moved argument: %s", arg);
5436 - options->color_moved = cm;
5437 - } else if (skip_prefix(arg, "--color-moved-ws=", &arg)) {
5449 + if (skip_prefix(arg, "--color-moved-ws=", &arg)) {
5450 unsigned cm = parse_color_moved_ws(arg);
5451 if (cm & COLOR_MOVED_WS_ERROR)
5452 return -1;