diff-parseopt: convert --[no-]color
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 5, 2019 at 19:30 UTC
8b81c26e5cfd139230d7f00660b9ed3586595545
1 file changed
+3
-9
diff.c
+3
-9
@@ -5148,6 +5148,8 @@ static void prep_parse_options(struct diff_options *options)
5148
PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_binary),
5149
OPT_BOOL(0, "full-index", &options->flags.full_index,
5150
N_("show full pre- and post-image object names on the \"index\" lines")),
5151
+ OPT_COLOR_FLAG(0, "color", &options->use_color,
5152
+ N_("show colored diff")),
5153
OPT_CALLBACK_F(0, "output-indicator-new",
5154
&options->output_indicators[OUTPUT_INDICATOR_NEW],
5155
N_("<char>"),
@@ -5268,15 +5270,7 @@ int diff_opt_parse(struct diff_options *options,
5270
return ac;
5271
5272
/* flags options */
5271
- if (skip_to_optional_arg_default(arg, "--color", &arg, "always")) {
5272
- int value = git_config_colorbool(NULL, arg);
5273
- if (value < 0)
5274
- return error("option `color' expects \"always\", \"auto\", or \"never\"");
5275
- options->use_color = value;
5276
- }
5277
- else if (!strcmp(arg, "--no-color"))
5278
- options->use_color = 0;
5279
- else if (!strcmp(arg, "--color-moved")) {
5273
+ if (!strcmp(arg, "--color-moved")) {
5274
if (diff_color_moved_default)
5275
options->color_moved = diff_color_moved_default;
5276
if (options->color_moved == COLOR_MOVED_NO)