vendor/libgit2/src/blame.c in rugged-0.27.5 vs vendor/libgit2/src/blame.c in rugged-0.27.7
- old
+ new
@@ -12,10 +12,11 @@
#include "git2/revwalk.h"
#include "git2/tree.h"
#include "git2/diff.h"
#include "git2/blob.h"
#include "git2/signature.h"
+#include "git2/mailmap.h"
#include "util.h"
#include "repository.h"
#include "blame_git.h"
@@ -130,10 +131,13 @@
{
git_blame_free(gbr);
return NULL;
}
+ if (opts.flags & GIT_BLAME_USE_MAILMAP)
+ git_mailmap_from_repository(&gbr->mailmap, repo);
+
return gbr;
}
void git_blame_free(git_blame *blame)
{
@@ -148,10 +152,12 @@
git_vector_free_deep(&blame->paths);
git_array_clear(blame->line_index);
+ git_mailmap_free(blame->mailmap);
+
git__free(blame->path);
git_blob_free(blame->final_blob);
git__free(blame);
}
@@ -277,22 +283,23 @@
*i = buf - blame->final_buf;
blame->num_lines = num + incomplete;
return blame->num_lines;
}
-static git_blame_hunk* hunk_from_entry(git_blame__entry *e)
+static git_blame_hunk* hunk_from_entry(git_blame__entry *e, git_blame *blame)
{
git_blame_hunk *h = new_hunk(
e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path);
if (!h)
return NULL;
git_oid_cpy(&h->final_commit_id, git_commit_id(e->suspect->commit));
git_oid_cpy(&h->orig_commit_id, git_commit_id(e->suspect->commit));
- git_signature_dup(&h->final_signature, git_commit_author(e->suspect->commit));
- git_signature_dup(&h->orig_signature, git_commit_author(e->suspect->commit));
+ git_commit_author_with_mailmap(
+ &h->final_signature, e->suspect->commit, blame->mailmap);
+ git_signature_dup(&h->orig_signature, h->final_signature);
h->boundary = e->is_boundary ? 1 : 0;
return h;
}
static int load_blob(git_blame *blame)
@@ -339,10 +346,10 @@
error = git_blame__like_git(blame, blame->options.flags);
cleanup:
for (ent = blame->ent; ent; ) {
git_blame__entry *e = ent->next;
- git_blame_hunk *h = hunk_from_entry(ent);
+ git_blame_hunk *h = hunk_from_entry(ent, blame);
git_vector_insert(&blame->hunks, h);
git_blame__free_entry(ent);
ent = e;