From 59311a9820df1c5f3463d1447458692fdbfef606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 24 Mar 2019 15:20:09 +0700 Subject: diff-parseopt: convert --[no-]color-moved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark one more string for translation while at there Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/diff.c b/diff.c index 8b65b03..de6c09e 100644 --- a/diff.c +++ b/diff.c @@ -4841,6 +4841,27 @@ static int diff_opt_char(const struct option *opt, return 0; } +static int diff_opt_color_moved(const struct option *opt, + const char *arg, int unset) +{ + struct diff_options *options = opt->value; + + if (unset) { + options->color_moved = COLOR_MOVED_NO; + } else if (!arg) { + if (diff_color_moved_default) + options->color_moved = diff_color_moved_default; + if (options->color_moved == COLOR_MOVED_NO) + options->color_moved = COLOR_MOVED_DEFAULT; + } else { + int cm = parse_color_moved(arg); + if (cm < 0) + return error(_("bad --color-moved argument: %s"), arg); + options->color_moved = cm; + } + return 0; +} + static int diff_opt_color_words(const struct option *opt, const char *arg, int unset) { @@ -5339,6 +5360,9 @@ static void prep_parse_options(struct diff_options *options) OPT_CALLBACK_F(0, "color-words", options, N_(""), N_("equivalent to --word-diff=color --word-diff-regex="), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_color_words), + OPT_CALLBACK_F(0, "color-moved", options, N_(""), + N_("move lines of code are colored differently"), + PARSE_OPT_OPTARG, diff_opt_color_moved), OPT_GROUP(N_("Diff other options")), OPT_CALLBACK_F(0, "relative", options, N_(""), @@ -5422,19 +5446,7 @@ int diff_opt_parse(struct diff_options *options, return ac; /* flags options */ - if (!strcmp(arg, "--color-moved")) { - if (diff_color_moved_default) - options->color_moved = diff_color_moved_default; - if (options->color_moved == COLOR_MOVED_NO) - options->color_moved = COLOR_MOVED_DEFAULT; - } else if (!strcmp(arg, "--no-color-moved")) - options->color_moved = COLOR_MOVED_NO; - else if (skip_prefix(arg, "--color-moved=", &arg)) { - int cm = parse_color_moved(arg); - if (cm < 0) - return error("bad --color-moved argument: %s", arg); - options->color_moved = cm; - } else if (skip_prefix(arg, "--color-moved-ws=", &arg)) { + if (skip_prefix(arg, "--color-moved-ws=", &arg)) { unsigned cm = parse_color_moved_ws(arg); if (cm & COLOR_MOVED_WS_ERROR) return -1; -- cgit v0.10.2-6-g49f6