@@ -1912,19 +1912,17 @@ static int color_words_output_graph_prefix(struct diff_words_data *diff_words)
19121912 }
19131913}
19141914
1915- static void fn_out_diff_words_aux (void * priv , char * line , unsigned long len )
1915+ static void fn_out_diff_words_aux (void * priv ,
1916+ long minus_first , long minus_len ,
1917+ long plus_first , long plus_len ,
1918+ const char * func , long funclen )
19161919{
19171920 struct diff_words_data * diff_words = priv ;
19181921 struct diff_words_style * style = diff_words -> style ;
1919- int minus_first , minus_len , plus_first , plus_len ;
19201922 const char * minus_begin , * minus_end , * plus_begin , * plus_end ;
19211923 struct diff_options * opt = diff_words -> opt ;
19221924 const char * line_prefix ;
19231925
1924- if (line [0 ] != '@' || parse_hunk_header (line , len ,
1925- & minus_first , & minus_len , & plus_first , & plus_len ))
1926- return ;
1927-
19281926 assert (opt );
19291927 line_prefix = diff_line_prefix (opt );
19301928
@@ -2074,8 +2072,8 @@ static void diff_words_show(struct diff_words_data *diff_words)
20742072 xpp .flags = 0 ;
20752073 /* as only the hunk header will be parsed, we need a 0-context */
20762074 xecfg .ctxlen = 0 ;
2077- if (xdi_diff_outf (& minus , & plus , fn_out_diff_words_aux , diff_words ,
2078- & xpp , & xecfg ))
2075+ if (xdi_diff_outf (& minus , & plus , fn_out_diff_words_aux , NULL ,
2076+ diff_words , & xpp , & xecfg ))
20792077 die ("unable to generate word diff" );
20802078 free (minus .ptr );
20812079 free (plus .ptr );
@@ -3130,6 +3128,15 @@ static int is_conflict_marker(const char *line, int marker_size, unsigned long l
31303128 return 1 ;
31313129}
31323130
3131+ static void checkdiff_consume_hunk (void * priv ,
3132+ long ob , long on , long nb , long nn ,
3133+ const char * func , long funclen )
3134+
3135+ {
3136+ struct checkdiff_t * data = priv ;
3137+ data -> lineno = nb - 1 ;
3138+ }
3139+
31333140static void checkdiff_consume (void * priv , char * line , unsigned long len )
31343141{
31353142 struct checkdiff_t * data = priv ;
@@ -3165,12 +3172,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
31653172 data -> o -> file , set , reset , ws );
31663173 } else if (line [0 ] == ' ' ) {
31673174 data -> lineno ++ ;
3168- } else if (line [0 ] == '@' ) {
3169- char * plus = strchr (line , '+' );
3170- if (plus )
3171- data -> lineno = strtol (plus , NULL , 10 ) - 1 ;
3172- else
3173- die ("invalid diff" );
31743175 }
31753176}
31763177
@@ -3526,8 +3527,8 @@ static void builtin_diff(const char *name_a,
35263527 xecfg .ctxlen = strtoul (v , NULL , 10 );
35273528 if (o -> word_diff )
35283529 init_diff_words_data (& ecbdata , o , one , two );
3529- if (xdi_diff_outf (& mf1 , & mf2 , fn_out_consume , & ecbdata ,
3530- & xpp , & xecfg ))
3530+ if (xdi_diff_outf (& mf1 , & mf2 , NULL , fn_out_consume ,
3531+ & ecbdata , & xpp , & xecfg ))
35313532 die ("unable to generate diff for %s" , one -> path );
35323533 if (o -> word_diff )
35333534 free_diff_words_data (& ecbdata );
@@ -3637,8 +3638,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
36373638 xpp .anchors_nr = o -> anchors_nr ;
36383639 xecfg .ctxlen = o -> context ;
36393640 xecfg .interhunkctxlen = o -> interhunkcontext ;
3640- if (xdi_diff_outf (& mf1 , & mf2 , diffstat_consume , diffstat ,
3641- & xpp , & xecfg ))
3641+ if (xdi_diff_outf (& mf1 , & mf2 , discard_hunk_line ,
3642+ diffstat_consume , diffstat , & xpp , & xecfg ))
36423643 die ("unable to generate diffstat for %s" , one -> path );
36433644 }
36443645
@@ -3686,7 +3687,8 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
36863687 memset (& xecfg , 0 , sizeof (xecfg ));
36873688 xecfg .ctxlen = 1 ; /* at least one context line */
36883689 xpp .flags = 0 ;
3689- if (xdi_diff_outf (& mf1 , & mf2 , checkdiff_consume , & data ,
3690+ if (xdi_diff_outf (& mf1 , & mf2 , checkdiff_consume_hunk ,
3691+ checkdiff_consume , & data ,
36903692 & xpp , & xecfg ))
36913693 die ("unable to generate checkdiff for %s" , one -> path );
36923694
@@ -5666,10 +5668,6 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)
56665668 struct patch_id_t * data = priv ;
56675669 int new_len ;
56685670
5669- /* Ignore line numbers when computing the SHA1 of the patch */
5670- if (starts_with (line , "@@ -" ))
5671- return ;
5672-
56735671 new_len = remove_space (line , len );
56745672
56755673 git_SHA1_Update (data -> ctx , line , new_len );
@@ -5771,8 +5769,8 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid
57715769 xpp .flags = 0 ;
57725770 xecfg .ctxlen = 3 ;
57735771 xecfg .flags = 0 ;
5774- if (xdi_diff_outf (& mf1 , & mf2 , patch_id_consume , & data ,
5775- & xpp , & xecfg ))
5772+ if (xdi_diff_outf (& mf1 , & mf2 , discard_hunk_line ,
5773+ patch_id_consume , & data , & xpp , & xecfg ))
57765774 return error ("unable to generate patch-id diff for %s" ,
57775775 p -> one -> path );
57785776 }
0 commit comments