@@ -583,11 +583,10 @@ static void emit_rewrite_diff(const char *name_a,
583
583
struct diff_options * o )
584
584
{
585
585
int lc_a , lc_b ;
586
- int color_diff = DIFF_OPT_TST (o , COLOR_DIFF );
587
586
const char * name_a_tab , * name_b_tab ;
588
- const char * metainfo = diff_get_color (color_diff , DIFF_METAINFO );
589
- const char * fraginfo = diff_get_color (color_diff , DIFF_FRAGINFO );
590
- const char * reset = diff_get_color (color_diff , DIFF_RESET );
587
+ const char * metainfo = diff_get_color (o -> use_color , DIFF_METAINFO );
588
+ const char * fraginfo = diff_get_color (o -> use_color , DIFF_FRAGINFO );
589
+ const char * reset = diff_get_color (o -> use_color , DIFF_RESET );
591
590
static struct strbuf a_name = STRBUF_INIT , b_name = STRBUF_INIT ;
592
591
const char * a_prefix , * b_prefix ;
593
592
char * data_one , * data_two ;
@@ -623,7 +622,7 @@ static void emit_rewrite_diff(const char *name_a,
623
622
size_two = fill_textconv (textconv_two , two , & data_two );
624
623
625
624
memset (& ecbdata , 0 , sizeof (ecbdata ));
626
- ecbdata .color_diff = color_diff ;
625
+ ecbdata .color_diff = o -> use_color > 0 ;
627
626
ecbdata .found_changesp = & o -> found_changes ;
628
627
ecbdata .ws_rule = whitespace_rule (name_b ? name_b : name_a );
629
628
ecbdata .opt = o ;
@@ -1004,7 +1003,7 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
1004
1003
1005
1004
const char * diff_get_color (int diff_use_color , enum color_diff ix )
1006
1005
{
1007
- if (diff_use_color )
1006
+ if (diff_use_color > 0 )
1008
1007
return diff_colors [ix ];
1009
1008
return "" ;
1010
1009
}
@@ -1786,11 +1785,10 @@ static int is_conflict_marker(const char *line, int marker_size, unsigned long l
1786
1785
static void checkdiff_consume (void * priv , char * line , unsigned long len )
1787
1786
{
1788
1787
struct checkdiff_t * data = priv ;
1789
- int color_diff = DIFF_OPT_TST (data -> o , COLOR_DIFF );
1790
1788
int marker_size = data -> conflict_marker_size ;
1791
- const char * ws = diff_get_color (color_diff , DIFF_WHITESPACE );
1792
- const char * reset = diff_get_color (color_diff , DIFF_RESET );
1793
- const char * set = diff_get_color (color_diff , DIFF_FILE_NEW );
1789
+ const char * ws = diff_get_color (data -> o -> use_color , DIFF_WHITESPACE );
1790
+ const char * reset = diff_get_color (data -> o -> use_color , DIFF_RESET );
1791
+ const char * set = diff_get_color (data -> o -> use_color , DIFF_FILE_NEW );
1794
1792
char * err ;
1795
1793
char * line_prefix = "" ;
1796
1794
struct strbuf * msgbuf ;
@@ -2135,7 +2133,7 @@ static void builtin_diff(const char *name_a,
2135
2133
memset (& xecfg , 0 , sizeof (xecfg ));
2136
2134
memset (& ecbdata , 0 , sizeof (ecbdata ));
2137
2135
ecbdata .label_path = lbl ;
2138
- ecbdata .color_diff = DIFF_OPT_TST ( o , COLOR_DIFF ) ;
2136
+ ecbdata .color_diff = o -> use_color > 0 ;
2139
2137
ecbdata .found_changesp = & o -> found_changes ;
2140
2138
ecbdata .ws_rule = whitespace_rule (name_b ? name_b : name_a );
2141
2139
if (ecbdata .ws_rule & WS_BLANK_AT_EOF )
@@ -2183,7 +2181,7 @@ static void builtin_diff(const char *name_a,
2183
2181
break ;
2184
2182
}
2185
2183
}
2186
- if (DIFF_OPT_TST ( o , COLOR_DIFF ) ) {
2184
+ if (o -> use_color > 0 ) {
2187
2185
struct diff_words_style * st = ecbdata .diff_words -> style ;
2188
2186
st -> old .color = diff_get_color_opt (o , DIFF_FILE_OLD );
2189
2187
st -> new .color = diff_get_color_opt (o , DIFF_FILE_NEW );
@@ -2833,7 +2831,7 @@ static void run_diff_cmd(const char *pgm,
2833
2831
*/
2834
2832
fill_metainfo (msg , name , other , one , two , o , p ,
2835
2833
& must_show_header ,
2836
- DIFF_OPT_TST ( o , COLOR_DIFF ) && !pgm );
2834
+ o -> use_color > 0 && !pgm );
2837
2835
xfrm_msg = msg -> len ? msg -> buf : NULL ;
2838
2836
}
2839
2837
@@ -2999,8 +2997,7 @@ void diff_setup(struct diff_options *options)
2999
2997
3000
2998
options -> change = diff_change ;
3001
2999
options -> add_remove = diff_addremove ;
3002
- if (diff_use_color_default > 0 )
3003
- DIFF_OPT_SET (options , COLOR_DIFF );
3000
+ options -> use_color = diff_use_color_default ;
3004
3001
options -> detect_rename = diff_detect_rename_default ;
3005
3002
3006
3003
if (diff_no_prefix ) {
@@ -3374,24 +3371,24 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
3374
3371
else if (!strcmp (arg , "--follow" ))
3375
3372
DIFF_OPT_SET (options , FOLLOW_RENAMES );
3376
3373
else if (!strcmp (arg , "--color" ))
3377
- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3374
+ options -> use_color = 1 ;
3378
3375
else if (!prefixcmp (arg , "--color=" )) {
3379
3376
int value = git_config_colorbool (NULL , arg + 8 , -1 );
3380
3377
if (value == 0 )
3381
- DIFF_OPT_CLR ( options , COLOR_DIFF ) ;
3378
+ options -> use_color = 0 ;
3382
3379
else if (value > 0 )
3383
- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3380
+ options -> use_color = 1 ;
3384
3381
else
3385
3382
return error ("option `color' expects \"always\", \"auto\", or \"never\"" );
3386
3383
}
3387
3384
else if (!strcmp (arg , "--no-color" ))
3388
- DIFF_OPT_CLR ( options , COLOR_DIFF ) ;
3385
+ options -> use_color = 0 ;
3389
3386
else if (!strcmp (arg , "--color-words" )) {
3390
- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3387
+ options -> use_color = 1 ;
3391
3388
options -> word_diff = DIFF_WORDS_COLOR ;
3392
3389
}
3393
3390
else if (!prefixcmp (arg , "--color-words=" )) {
3394
- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3391
+ options -> use_color = 1 ;
3395
3392
options -> word_diff = DIFF_WORDS_COLOR ;
3396
3393
options -> word_regex = arg + 14 ;
3397
3394
}
@@ -3404,7 +3401,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
3404
3401
if (!strcmp (type , "plain" ))
3405
3402
options -> word_diff = DIFF_WORDS_PLAIN ;
3406
3403
else if (!strcmp (type , "color" )) {
3407
- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3404
+ options -> use_color = 1 ;
3408
3405
options -> word_diff = DIFF_WORDS_COLOR ;
3409
3406
}
3410
3407
else if (!strcmp (type , "porcelain" ))
0 commit comments