88#include "log-tree.h"
99#include "refs.h"
1010#include "userdiff.h"
11+ #include "sha1-array.h"
1112
1213static struct combine_diff_path * intersect_paths (struct combine_diff_path * curr , int n , int num_parent )
1314{
@@ -1116,15 +1117,14 @@ static void handle_combined_callback(struct diff_options *opt,
11161117}
11171118
11181119void diff_tree_combined (const unsigned char * sha1 ,
1119- const unsigned char parent [][20 ],
1120- int num_parent ,
1120+ const struct sha1_array * parents ,
11211121 int dense ,
11221122 struct rev_info * rev )
11231123{
11241124 struct diff_options * opt = & rev -> diffopt ;
11251125 struct diff_options diffopts ;
11261126 struct combine_diff_path * p , * paths = NULL ;
1127- int i , num_paths , needsep , show_log_first ;
1127+ int i , num_paths , needsep , show_log_first , num_parent = parents -> nr ;
11281128
11291129 diffopts = * opt ;
11301130 diffopts .output_format = DIFF_FORMAT_NO_OUTPUT ;
@@ -1144,7 +1144,7 @@ void diff_tree_combined(const unsigned char *sha1,
11441144 diffopts .output_format = stat_opt ;
11451145 else
11461146 diffopts .output_format = DIFF_FORMAT_NO_OUTPUT ;
1147- diff_tree_sha1 (parent [i ], sha1 , "" , & diffopts );
1147+ diff_tree_sha1 (parents -> sha1 [i ], sha1 , "" , & diffopts );
11481148 diffcore_std (& diffopts );
11491149 paths = intersect_paths (paths , i , num_parent );
11501150
@@ -1199,22 +1199,14 @@ void diff_tree_combined(const unsigned char *sha1,
11991199void diff_tree_combined_merge (const unsigned char * sha1 ,
12001200 int dense , struct rev_info * rev )
12011201{
1202- int num_parent ;
1203- const unsigned char (* parent )[20 ];
12041202 struct commit * commit = lookup_commit (sha1 );
1205- struct commit_list * parents ;
1206-
1207- /* count parents */
1208- for (parents = commit -> parents , num_parent = 0 ;
1209- parents ;
1210- parents = parents -> next , num_parent ++ )
1211- ; /* nothing */
1212-
1213- parent = xmalloc (num_parent * sizeof (* parent ));
1214- for (parents = commit -> parents , num_parent = 0 ;
1215- parents ;
1216- parents = parents -> next , num_parent ++ )
1217- hashcpy ((unsigned char * )(parent + num_parent ),
1218- parents -> item -> object .sha1 );
1219- diff_tree_combined (sha1 , parent , num_parent , dense , rev );
1203+ struct commit_list * parent = commit -> parents ;
1204+ struct sha1_array parents = SHA1_ARRAY_INIT ;
1205+
1206+ while (parent ) {
1207+ sha1_array_append (& parents , parent -> item -> object .sha1 );
1208+ parent = parent -> next ;
1209+ }
1210+ diff_tree_combined (sha1 , & parents , dense , rev );
1211+ sha1_array_clear (& parents );
12201212}
0 commit comments