@@ -583,11 +583,10 @@ static void emit_rewrite_diff(const char *name_a,
583583 struct diff_options * o )
584584{
585585 int lc_a , lc_b ;
586- int color_diff = DIFF_OPT_TST (o , COLOR_DIFF );
587586 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 );
591590 static struct strbuf a_name = STRBUF_INIT , b_name = STRBUF_INIT ;
592591 const char * a_prefix , * b_prefix ;
593592 char * data_one , * data_two ;
@@ -623,7 +622,7 @@ static void emit_rewrite_diff(const char *name_a,
623622 size_two = fill_textconv (textconv_two , two , & data_two );
624623
625624 memset (& ecbdata , 0 , sizeof (ecbdata ));
626- ecbdata .color_diff = color_diff ;
625+ ecbdata .color_diff = o -> use_color > 0 ;
627626 ecbdata .found_changesp = & o -> found_changes ;
628627 ecbdata .ws_rule = whitespace_rule (name_b ? name_b : name_a );
629628 ecbdata .opt = o ;
@@ -1004,7 +1003,7 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
10041003
10051004const char * diff_get_color (int diff_use_color , enum color_diff ix )
10061005{
1007- if (diff_use_color )
1006+ if (diff_use_color > 0 )
10081007 return diff_colors [ix ];
10091008 return "" ;
10101009}
@@ -1786,11 +1785,10 @@ static int is_conflict_marker(const char *line, int marker_size, unsigned long l
17861785static void checkdiff_consume (void * priv , char * line , unsigned long len )
17871786{
17881787 struct checkdiff_t * data = priv ;
1789- int color_diff = DIFF_OPT_TST (data -> o , COLOR_DIFF );
17901788 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 );
17941792 char * err ;
17951793 char * line_prefix = "" ;
17961794 struct strbuf * msgbuf ;
@@ -2135,7 +2133,7 @@ static void builtin_diff(const char *name_a,
21352133 memset (& xecfg , 0 , sizeof (xecfg ));
21362134 memset (& ecbdata , 0 , sizeof (ecbdata ));
21372135 ecbdata .label_path = lbl ;
2138- ecbdata .color_diff = DIFF_OPT_TST ( o , COLOR_DIFF ) ;
2136+ ecbdata .color_diff = o -> use_color > 0 ;
21392137 ecbdata .found_changesp = & o -> found_changes ;
21402138 ecbdata .ws_rule = whitespace_rule (name_b ? name_b : name_a );
21412139 if (ecbdata .ws_rule & WS_BLANK_AT_EOF )
@@ -2183,7 +2181,7 @@ static void builtin_diff(const char *name_a,
21832181 break ;
21842182 }
21852183 }
2186- if (DIFF_OPT_TST ( o , COLOR_DIFF ) ) {
2184+ if (o -> use_color > 0 ) {
21872185 struct diff_words_style * st = ecbdata .diff_words -> style ;
21882186 st -> old .color = diff_get_color_opt (o , DIFF_FILE_OLD );
21892187 st -> new .color = diff_get_color_opt (o , DIFF_FILE_NEW );
@@ -2833,7 +2831,7 @@ static void run_diff_cmd(const char *pgm,
28332831 */
28342832 fill_metainfo (msg , name , other , one , two , o , p ,
28352833 & must_show_header ,
2836- DIFF_OPT_TST ( o , COLOR_DIFF ) && !pgm );
2834+ o -> use_color > 0 && !pgm );
28372835 xfrm_msg = msg -> len ? msg -> buf : NULL ;
28382836 }
28392837
@@ -2999,8 +2997,7 @@ void diff_setup(struct diff_options *options)
29992997
30002998 options -> change = diff_change ;
30012999 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 ;
30043001 options -> detect_rename = diff_detect_rename_default ;
30053002
30063003 if (diff_no_prefix ) {
@@ -3374,24 +3371,24 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
33743371 else if (!strcmp (arg , "--follow" ))
33753372 DIFF_OPT_SET (options , FOLLOW_RENAMES );
33763373 else if (!strcmp (arg , "--color" ))
3377- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3374+ options -> use_color = 1 ;
33783375 else if (!prefixcmp (arg , "--color=" )) {
33793376 int value = git_config_colorbool (NULL , arg + 8 , -1 );
33803377 if (value == 0 )
3381- DIFF_OPT_CLR ( options , COLOR_DIFF ) ;
3378+ options -> use_color = 0 ;
33823379 else if (value > 0 )
3383- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3380+ options -> use_color = 1 ;
33843381 else
33853382 return error ("option `color' expects \"always\", \"auto\", or \"never\"" );
33863383 }
33873384 else if (!strcmp (arg , "--no-color" ))
3388- DIFF_OPT_CLR ( options , COLOR_DIFF ) ;
3385+ options -> use_color = 0 ;
33893386 else if (!strcmp (arg , "--color-words" )) {
3390- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3387+ options -> use_color = 1 ;
33913388 options -> word_diff = DIFF_WORDS_COLOR ;
33923389 }
33933390 else if (!prefixcmp (arg , "--color-words=" )) {
3394- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3391+ options -> use_color = 1 ;
33953392 options -> word_diff = DIFF_WORDS_COLOR ;
33963393 options -> word_regex = arg + 14 ;
33973394 }
@@ -3404,7 +3401,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
34043401 if (!strcmp (type , "plain" ))
34053402 options -> word_diff = DIFF_WORDS_PLAIN ;
34063403 else if (!strcmp (type , "color" )) {
3407- DIFF_OPT_SET ( options , COLOR_DIFF ) ;
3404+ options -> use_color = 1 ;
34083405 options -> word_diff = DIFF_WORDS_COLOR ;
34093406 }
34103407 else if (!strcmp (type , "porcelain" ))
0 commit comments