summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-03-24 08:20:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-03-24 13:21:23 (GMT)
commit59311a9820df1c5f3463d1447458692fdbfef606 (patch)
treee30ce71d119bdbd7193f76afbdb19ee9a6dc064a /diff.c
parent16ed6c97cc6cc3de2637e9df8bb057e1254667c9 (diff)
downloadgit-59311a9820df1c5f3463d1447458692fdbfef606.zip
git-59311a9820df1c5f3463d1447458692fdbfef606.tar.gz
git-59311a9820df1c5f3463d1447458692fdbfef606.tar.bz2
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c38
1 files changed, 25 insertions, 13 deletions
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_("<regex>"),
N_("equivalent to --word-diff=color --word-diff-regex=<regex>"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_color_words),
+ OPT_CALLBACK_F(0, "color-moved", options, N_("<mode>"),
+ 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_("<prefix>"),
@@ -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;