@@ -357,7 +357,6 @@ struct emit_callback {
357357 const char * * label_path ;
358358 struct diff_words_data * diff_words ;
359359 struct diff_options * opt ;
360- int * found_changesp ;
361360 struct strbuf * header ;
362361};
363362
@@ -725,7 +724,6 @@ static void emit_rewrite_diff(const char *name_a,
725724
726725 memset (& ecbdata , 0 , sizeof (ecbdata ));
727726 ecbdata .color_diff = want_color (o -> use_color );
728- ecbdata .found_changesp = & o -> found_changes ;
729727 ecbdata .ws_rule = whitespace_rule (name_b );
730728 ecbdata .opt = o ;
731729 if (ecbdata .ws_rule & WS_BLANK_AT_EOF ) {
@@ -1219,22 +1217,23 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12191217 struct diff_options * o = ecbdata -> opt ;
12201218 const char * line_prefix = diff_line_prefix (o );
12211219
1220+ o -> found_changes = 1 ;
1221+
12221222 if (ecbdata -> header ) {
1223- fprintf (ecbdata -> opt -> file , "%s" , ecbdata -> header -> buf );
1223+ fprintf (o -> file , "%s" , ecbdata -> header -> buf );
12241224 strbuf_reset (ecbdata -> header );
12251225 ecbdata -> header = NULL ;
12261226 }
1227- * (ecbdata -> found_changesp ) = 1 ;
12281227
12291228 if (ecbdata -> label_path [0 ]) {
12301229 const char * name_a_tab , * name_b_tab ;
12311230
12321231 name_a_tab = strchr (ecbdata -> label_path [0 ], ' ' ) ? "\t" : "" ;
12331232 name_b_tab = strchr (ecbdata -> label_path [1 ], ' ' ) ? "\t" : "" ;
12341233
1235- fprintf (ecbdata -> opt -> file , "%s%s--- %s%s%s\n" ,
1234+ fprintf (o -> file , "%s%s--- %s%s%s\n" ,
12361235 line_prefix , meta , ecbdata -> label_path [0 ], reset , name_a_tab );
1237- fprintf (ecbdata -> opt -> file , "%s%s+++ %s%s%s\n" ,
1236+ fprintf (o -> file , "%s%s+++ %s%s%s\n" ,
12381237 line_prefix , meta , ecbdata -> label_path [1 ], reset , name_b_tab );
12391238 ecbdata -> label_path [0 ] = ecbdata -> label_path [1 ] = NULL ;
12401239 }
@@ -1252,15 +1251,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12521251 find_lno (line , ecbdata );
12531252 emit_hunk_header (ecbdata , line , len );
12541253 if (line [len - 1 ] != '\n' )
1255- putc ('\n' , ecbdata -> opt -> file );
1256- return ;
1257- }
1258-
1259- if (len < 1 ) {
1260- emit_line (ecbdata -> opt , reset , reset , line , len );
1261- if (ecbdata -> diff_words
1262- && ecbdata -> diff_words -> type == DIFF_WORDS_PORCELAIN )
1263- fputs ("~\n" , ecbdata -> opt -> file );
1254+ putc ('\n' , o -> file );
12641255 return ;
12651256 }
12661257
@@ -1285,8 +1276,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12851276 }
12861277 diff_words_flush (ecbdata );
12871278 if (ecbdata -> diff_words -> type == DIFF_WORDS_PORCELAIN ) {
1288- emit_line (ecbdata -> opt , context , reset , line , len );
1289- fputs ("~\n" , ecbdata -> opt -> file );
1279+ emit_line (o , context , reset , line , len );
1280+ fputs ("~\n" , o -> file );
12901281 } else {
12911282 /*
12921283 * Skip the prefix character, if any. With
@@ -1297,7 +1288,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12971288 line ++ ;
12981289 len -- ;
12991290 }
1300- emit_line (ecbdata -> opt , context , reset , line , len );
1291+ emit_line (o , context , reset , line , len );
13011292 }
13021293 return ;
13031294 }
@@ -1319,8 +1310,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
13191310 default :
13201311 /* incomplete line at the end */
13211312 ecbdata -> lno_in_preimage ++ ;
1322- emit_line (ecbdata -> opt ,
1323- diff_get_color (ecbdata -> color_diff , DIFF_CONTEXT ),
1313+ emit_line (o , diff_get_color (ecbdata -> color_diff , DIFF_CONTEXT ),
13241314 reset , line , len );
13251315 break ;
13261316 }
@@ -2452,7 +2442,6 @@ static void builtin_diff(const char *name_a,
24522442 memset (& ecbdata , 0 , sizeof (ecbdata ));
24532443 ecbdata .label_path = lbl ;
24542444 ecbdata .color_diff = want_color (o -> use_color );
2455- ecbdata .found_changesp = & o -> found_changes ;
24562445 ecbdata .ws_rule = whitespace_rule (name_b );
24572446 if (ecbdata .ws_rule & WS_BLANK_AT_EOF )
24582447 check_blank_at_eof (& mf1 , & mf2 , & ecbdata );
0 commit comments