@@ -354,7 +354,6 @@ struct emit_callback {
354354 const char * * label_path ;
355355 struct diff_words_data * diff_words ;
356356 struct diff_options * opt ;
357- int * found_changesp ;
358357 struct strbuf * header ;
359358};
360359
@@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,
722721
723722 memset (& ecbdata , 0 , sizeof (ecbdata ));
724723 ecbdata .color_diff = want_color (o -> use_color );
725- ecbdata .found_changesp = & o -> found_changes ;
726724 ecbdata .ws_rule = whitespace_rule (name_b );
727725 ecbdata .opt = o ;
728726 if (ecbdata .ws_rule & WS_BLANK_AT_EOF ) {
@@ -1216,22 +1214,23 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12161214 struct diff_options * o = ecbdata -> opt ;
12171215 const char * line_prefix = diff_line_prefix (o );
12181216
1217+ o -> found_changes = 1 ;
1218+
12191219 if (ecbdata -> header ) {
1220- fprintf (ecbdata -> opt -> file , "%s" , ecbdata -> header -> buf );
1220+ fprintf (o -> file , "%s" , ecbdata -> header -> buf );
12211221 strbuf_reset (ecbdata -> header );
12221222 ecbdata -> header = NULL ;
12231223 }
1224- * (ecbdata -> found_changesp ) = 1 ;
12251224
12261225 if (ecbdata -> label_path [0 ]) {
12271226 const char * name_a_tab , * name_b_tab ;
12281227
12291228 name_a_tab = strchr (ecbdata -> label_path [0 ], ' ' ) ? "\t" : "" ;
12301229 name_b_tab = strchr (ecbdata -> label_path [1 ], ' ' ) ? "\t" : "" ;
12311230
1232- fprintf (ecbdata -> opt -> file , "%s%s--- %s%s%s\n" ,
1231+ fprintf (o -> file , "%s%s--- %s%s%s\n" ,
12331232 line_prefix , meta , ecbdata -> label_path [0 ], reset , name_a_tab );
1234- fprintf (ecbdata -> opt -> file , "%s%s+++ %s%s%s\n" ,
1233+ fprintf (o -> file , "%s%s+++ %s%s%s\n" ,
12351234 line_prefix , meta , ecbdata -> label_path [1 ], reset , name_b_tab );
12361235 ecbdata -> label_path [0 ] = ecbdata -> label_path [1 ] = NULL ;
12371236 }
@@ -1249,15 +1248,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12491248 find_lno (line , ecbdata );
12501249 emit_hunk_header (ecbdata , line , len );
12511250 if (line [len - 1 ] != '\n' )
1252- putc ('\n' , ecbdata -> opt -> file );
1253- return ;
1254- }
1255-
1256- if (len < 1 ) {
1257- emit_line (ecbdata -> opt , reset , reset , line , len );
1258- if (ecbdata -> diff_words
1259- && ecbdata -> diff_words -> type == DIFF_WORDS_PORCELAIN )
1260- fputs ("~\n" , ecbdata -> opt -> file );
1251+ putc ('\n' , o -> file );
12611252 return ;
12621253 }
12631254
@@ -1282,8 +1273,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12821273 }
12831274 diff_words_flush (ecbdata );
12841275 if (ecbdata -> diff_words -> type == DIFF_WORDS_PORCELAIN ) {
1285- emit_line (ecbdata -> opt , context , reset , line , len );
1286- fputs ("~\n" , ecbdata -> opt -> file );
1276+ emit_line (o , context , reset , line , len );
1277+ fputs ("~\n" , o -> file );
12871278 } else {
12881279 /*
12891280 * Skip the prefix character, if any. With
@@ -1294,7 +1285,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12941285 line ++ ;
12951286 len -- ;
12961287 }
1297- emit_line (ecbdata -> opt , context , reset , line , len );
1288+ emit_line (o , context , reset , line , len );
12981289 }
12991290 return ;
13001291 }
@@ -1316,8 +1307,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
13161307 default :
13171308 /* incomplete line at the end */
13181309 ecbdata -> lno_in_preimage ++ ;
1319- emit_line (ecbdata -> opt ,
1320- diff_get_color (ecbdata -> color_diff , DIFF_CONTEXT ),
1310+ emit_line (o , diff_get_color (ecbdata -> color_diff , DIFF_CONTEXT ),
13211311 reset , line , len );
13221312 break ;
13231313 }
@@ -2438,7 +2428,6 @@ static void builtin_diff(const char *name_a,
24382428 memset (& ecbdata , 0 , sizeof (ecbdata ));
24392429 ecbdata .label_path = lbl ;
24402430 ecbdata .color_diff = want_color (o -> use_color );
2441- ecbdata .found_changesp = & o -> found_changes ;
24422431 ecbdata .ws_rule = whitespace_rule (name_b );
24432432 if (ecbdata .ws_rule & WS_BLANK_AT_EOF )
24442433 check_blank_at_eof (& mf1 , & mf2 , & ecbdata );
0 commit comments