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>
This commit is contained in:
parent
16ed6c97cc
commit
59311a9820
38
diff.c
38
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;
|
||||
|
Loading…
Reference in New Issue
Block a user