@@ -60,10 +60,11 @@ static bool hunk_starts_at_or_after_line(git_blame_hunk *hunk, size_t line)
6060}
6161
6262static git_blame_hunk * new_hunk (
63- size_t start ,
64- size_t lines ,
65- size_t orig_start ,
66- const char * path )
63+ size_t start ,
64+ size_t lines ,
65+ size_t orig_start ,
66+ const char * path ,
67+ git_blame * blame )
6768{
6869 git_blame_hunk * hunk = git__calloc (1 , sizeof (git_blame_hunk ));
6970 if (!hunk ) return NULL ;
@@ -72,8 +73,8 @@ static git_blame_hunk *new_hunk(
7273 hunk -> final_start_line_number = start ;
7374 hunk -> orig_start_line_number = orig_start ;
7475 hunk -> orig_path = path ? git__strdup (path ) : NULL ;
75- git_oid_clear (& hunk -> orig_commit_id , GIT_OID_SHA1 );
76- git_oid_clear (& hunk -> final_commit_id , GIT_OID_SHA1 );
76+ git_oid_clear (& hunk -> orig_commit_id , blame -> repository -> oid_type );
77+ git_oid_clear (& hunk -> final_commit_id , blame -> repository -> oid_type );
7778
7879 return hunk ;
7980}
@@ -86,13 +87,14 @@ static void free_hunk(git_blame_hunk *hunk)
8687 git__free (hunk );
8788}
8889
89- static git_blame_hunk * dup_hunk (git_blame_hunk * hunk )
90+ static git_blame_hunk * dup_hunk (git_blame_hunk * hunk , git_blame * blame )
9091{
9192 git_blame_hunk * newhunk = new_hunk (
9293 hunk -> final_start_line_number ,
9394 hunk -> lines_in_hunk ,
9495 hunk -> orig_start_line_number ,
95- hunk -> orig_path );
96+ hunk -> orig_path ,
97+ blame );
9698
9799 if (!newhunk )
98100 return NULL ;
@@ -237,7 +239,8 @@ static git_blame_hunk *split_hunk_in_vector(
237239 git_vector * vec ,
238240 git_blame_hunk * hunk ,
239241 size_t rel_line ,
240- bool return_new )
242+ bool return_new ,
243+ git_blame * blame )
241244{
242245 size_t new_line_count ;
243246 git_blame_hunk * nh ;
@@ -250,8 +253,9 @@ static git_blame_hunk *split_hunk_in_vector(
250253 }
251254
252255 new_line_count = hunk -> lines_in_hunk - rel_line ;
253- nh = new_hunk (hunk -> final_start_line_number + rel_line , new_line_count ,
254- hunk -> orig_start_line_number + rel_line , hunk -> orig_path );
256+ nh = new_hunk (hunk -> final_start_line_number + rel_line ,
257+ new_line_count , hunk -> orig_start_line_number + rel_line ,
258+ hunk -> orig_path , blame );
255259
256260 if (!nh )
257261 return NULL ;
@@ -304,7 +308,8 @@ static int index_blob_lines(git_blame *blame)
304308static git_blame_hunk * hunk_from_entry (git_blame__entry * e , git_blame * blame )
305309{
306310 git_blame_hunk * h = new_hunk (
307- e -> lno + 1 , e -> num_lines , e -> s_lno + 1 , e -> suspect -> path );
311+ e -> lno + 1 , e -> num_lines , e -> s_lno + 1 , e -> suspect -> path ,
312+ blame );
308313
309314 if (!h )
310315 return NULL ;
@@ -445,14 +450,16 @@ static int buffer_hunk_cb(
445450 blame -> current_hunk = (git_blame_hunk * )git_blame_get_hunk_byline (blame , wedge_line );
446451 if (!blame -> current_hunk ) {
447452 /* Line added at the end of the file */
448- blame -> current_hunk = new_hunk (wedge_line , 0 , wedge_line , blame -> path );
453+ blame -> current_hunk = new_hunk (wedge_line , 0 , wedge_line ,
454+ blame -> path , blame );
449455 GIT_ERROR_CHECK_ALLOC (blame -> current_hunk );
450456
451457 git_vector_insert (& blame -> hunks , blame -> current_hunk );
452458 } else if (!hunk_starts_at_or_after_line (blame -> current_hunk , wedge_line )){
453459 /* If this hunk doesn't start between existing hunks, split a hunk up so it does */
454460 blame -> current_hunk = split_hunk_in_vector (& blame -> hunks , blame -> current_hunk ,
455- wedge_line - blame -> current_hunk -> orig_start_line_number , true);
461+ wedge_line - blame -> current_hunk -> orig_start_line_number , true,
462+ blame );
456463 GIT_ERROR_CHECK_ALLOC (blame -> current_hunk );
457464 }
458465
@@ -481,7 +488,7 @@ static int buffer_line_cb(
481488 } else {
482489 /* Create a new buffer-blame hunk with this line */
483490 shift_hunks_by (& blame -> hunks , blame -> current_diff_line , 1 );
484- blame -> current_hunk = new_hunk (blame -> current_diff_line , 1 , 0 , blame -> path );
491+ blame -> current_hunk = new_hunk (blame -> current_diff_line , 1 , 0 , blame -> path , blame );
485492 GIT_ERROR_CHECK_ALLOC (blame -> current_hunk );
486493
487494 git_vector_insert_sorted (& blame -> hunks , blame -> current_hunk , NULL );
@@ -529,7 +536,7 @@ int git_blame_buffer(
529536
530537 /* Duplicate all of the hunk structures in the reference blame */
531538 git_vector_foreach (& reference -> hunks , i , hunk ) {
532- git_blame_hunk * h = dup_hunk (hunk );
539+ git_blame_hunk * h = dup_hunk (hunk , blame );
533540 GIT_ERROR_CHECK_ALLOC (h );
534541
535542 git_vector_insert (& blame -> hunks , h );
0 commit comments