@@ -132,6 +132,9 @@ git_blame* git_blame__alloc(
132132 return NULL ;
133133 }
134134
135+ if (opts .flags & GIT_BLAME_USE_MAILMAP )
136+ git_mailmap_from_repo (& gbr -> mailmap , repo );
137+
135138 return gbr ;
136139}
137140
@@ -150,6 +153,8 @@ void git_blame_free(git_blame *blame)
150153
151154 git_array_clear (blame -> line_index );
152155
156+ git_mailmap_free (blame -> mailmap );
157+
153158 git__free (blame -> path );
154159 git_blob_free (blame -> final_blob );
155160 git__free (blame );
@@ -279,7 +284,7 @@ static int index_blob_lines(git_blame *blame)
279284 return blame -> num_lines ;
280285}
281286
282- static git_blame_hunk * hunk_from_entry (git_blame__entry * e )
287+ static git_blame_hunk * hunk_from_entry (git_blame__entry * e , git_blame * blame )
283288{
284289 git_blame_hunk * h = new_hunk (
285290 e -> lno + 1 , e -> num_lines , e -> s_lno + 1 , e -> suspect -> path );
@@ -289,8 +294,9 @@ static git_blame_hunk* hunk_from_entry(git_blame__entry *e)
289294
290295 git_oid_cpy (& h -> final_commit_id , git_commit_id (e -> suspect -> commit ));
291296 git_oid_cpy (& h -> orig_commit_id , git_commit_id (e -> suspect -> commit ));
292- git_signature_dup (& h -> final_signature , git_commit_author (e -> suspect -> commit ));
293- git_signature_dup (& h -> orig_signature , git_commit_author (e -> suspect -> commit ));
297+ git_commit_author_with_mailmap (
298+ & h -> final_signature , e -> suspect -> commit , blame -> mailmap );
299+ git_signature_dup (& h -> orig_signature , h -> final_signature );
294300 h -> boundary = e -> is_boundary ? 1 : 0 ;
295301 return h ;
296302}
@@ -341,7 +347,7 @@ static int blame_internal(git_blame *blame)
341347cleanup :
342348 for (ent = blame -> ent ; ent ; ) {
343349 git_blame__entry * e = ent -> next ;
344- git_blame_hunk * h = hunk_from_entry (ent );
350+ git_blame_hunk * h = hunk_from_entry (ent , blame );
345351
346352 git_vector_insert (& blame -> hunks , h );
347353
0 commit comments