@@ -88,6 +88,20 @@ struct origin {
8888 char path [FLEX_ARRAY ];
8989};
9090
91+ static int diff_hunks (mmfile_t * file_a , mmfile_t * file_b , long ctxlen ,
92+ xdl_emit_hunk_consume_func_t hunk_func , void * cb_data )
93+ {
94+ xpparam_t xpp = {0 };
95+ xdemitconf_t xecfg = {0 };
96+ xdemitcb_t ecb = {NULL };
97+
98+ xpp .flags = xdl_opts ;
99+ xecfg .ctxlen = ctxlen ;
100+ xecfg .hunk_func = hunk_func ;
101+ ecb .priv = cb_data ;
102+ return xdi_diff (file_a , file_b , & xpp , & xecfg , & ecb );
103+ }
104+
91105/*
92106 * Prepare diff_filespec and convert it using diff textconv API
93107 * if the textconv driver exists.
@@ -759,12 +773,14 @@ struct blame_chunk_cb_data {
759773 long tlno ;
760774};
761775
762- static void blame_chunk_cb (void * data , long same , long p_next , long t_next )
776+ static int blame_chunk_cb (long start_a , long count_a ,
777+ long start_b , long count_b , void * data )
763778{
764779 struct blame_chunk_cb_data * d = data ;
765- blame_chunk (d -> sb , d -> tlno , d -> plno , same , d -> target , d -> parent );
766- d -> plno = p_next ;
767- d -> tlno = t_next ;
780+ blame_chunk (d -> sb , d -> tlno , d -> plno , start_b , d -> target , d -> parent );
781+ d -> plno = start_a + count_a ;
782+ d -> tlno = start_b + count_b ;
783+ return 0 ;
768784}
769785
770786/*
@@ -779,8 +795,7 @@ static int pass_blame_to_parent(struct scoreboard *sb,
779795 int last_in_target ;
780796 mmfile_t file_p , file_o ;
781797 struct blame_chunk_cb_data d ;
782- xpparam_t xpp ;
783- xdemitconf_t xecfg ;
798+
784799 memset (& d , 0 , sizeof (d ));
785800 d .sb = sb ; d .target = target ; d .parent = parent ;
786801 last_in_target = find_last_in_target (sb , target );
@@ -791,11 +806,7 @@ static int pass_blame_to_parent(struct scoreboard *sb,
791806 fill_origin_blob (& sb -> revs -> diffopt , target , & file_o );
792807 num_get_patch ++ ;
793808
794- memset (& xpp , 0 , sizeof (xpp ));
795- xpp .flags = xdl_opts ;
796- memset (& xecfg , 0 , sizeof (xecfg ));
797- xecfg .ctxlen = 0 ;
798- xdi_diff_hunks (& file_p , & file_o , blame_chunk_cb , & d , & xpp , & xecfg );
809+ diff_hunks (& file_p , & file_o , 0 , blame_chunk_cb , & d );
799810 /* The rest (i.e. anything after tlno) are the same as the parent */
800811 blame_chunk (sb , d .tlno , d .plno , last_in_target , target , parent );
801812
@@ -899,12 +910,15 @@ struct handle_split_cb_data {
899910 long tlno ;
900911};
901912
902- static void handle_split_cb (void * data , long same , long p_next , long t_next )
913+ static int handle_split_cb (long start_a , long count_a ,
914+ long start_b , long count_b , void * data )
903915{
904916 struct handle_split_cb_data * d = data ;
905- handle_split (d -> sb , d -> ent , d -> tlno , d -> plno , same , d -> parent , d -> split );
906- d -> plno = p_next ;
907- d -> tlno = t_next ;
917+ handle_split (d -> sb , d -> ent , d -> tlno , d -> plno , start_b , d -> parent ,
918+ d -> split );
919+ d -> plno = start_a + count_a ;
920+ d -> tlno = start_b + count_b ;
921+ return 0 ;
908922}
909923
910924/*
@@ -922,8 +936,7 @@ static void find_copy_in_blob(struct scoreboard *sb,
922936 int cnt ;
923937 mmfile_t file_o ;
924938 struct handle_split_cb_data d ;
925- xpparam_t xpp ;
926- xdemitconf_t xecfg ;
939+
927940 memset (& d , 0 , sizeof (d ));
928941 d .sb = sb ; d .ent = ent ; d .parent = parent ; d .split = split ;
929942 /*
@@ -943,12 +956,8 @@ static void find_copy_in_blob(struct scoreboard *sb,
943956 * file_o is a part of final image we are annotating.
944957 * file_p partially may match that image.
945958 */
946- memset (& xpp , 0 , sizeof (xpp ));
947- xpp .flags = xdl_opts ;
948- memset (& xecfg , 0 , sizeof (xecfg ));
949- xecfg .ctxlen = 1 ;
950959 memset (split , 0 , sizeof (struct blame_entry [3 ]));
951- xdi_diff_hunks (file_p , & file_o , handle_split_cb , & d , & xpp , & xecfg );
960+ diff_hunks (file_p , & file_o , 1 , handle_split_cb , & d );
952961 /* remainder, if any, all match the preimage */
953962 handle_split (sb , ent , d .tlno , d .plno , ent -> num_lines , parent , split );
954963}
0 commit comments