Commit c1ca2b67 by Ben Straub

Include signatures in blame hunks

parent ebd67243
......@@ -128,22 +128,20 @@ int main(int argc, char *argv[])
while (i < git_blob_rawsize(blob)) {
const char *eol = strchr(rawdata+i, '\n');
char oid[10] = {0};
git_commit *hunkcommit;
const git_signature *sig;
const git_blame_hunk *hunk = git_blame_get_hunk_byline(blame, line);
if (hunk) {
char sig[128] = {0};
git_oid_tostr(oid, 10, &hunk->final_commit_id);
check(git_commit_lookup(&hunkcommit, repo, &hunk->final_commit_id), "Commit lookup error");
sig = git_commit_author(hunkcommit);
snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email);
printf("%s ( %-30s %3d) %.*s\n",
oid,
sig->name,
sig,
line,
(int)(eol-rawdata-i),
rawdata+i);
git_commit_free(hunkcommit);
}
i = eol - rawdata + 1;
......
......@@ -103,10 +103,12 @@ typedef struct git_blame_hunk {
git_oid final_commit_id;
uint16_t final_start_line_number;
git_signature *final_signature;
git_oid orig_commit_id;
const char *orig_path;
uint16_t orig_start_line_number;
git_signature *orig_signature;
char boundary;
} git_blame_hunk;
......
......@@ -12,6 +12,7 @@
#include "git2/tree.h"
#include "git2/diff.h"
#include "git2/blob.h"
#include "git2/signature.h"
#include "util.h"
#include "repository.h"
#include "blame_git.h"
......@@ -80,6 +81,8 @@ static git_blame_hunk* dup_hunk(git_blame_hunk *hunk)
static void free_hunk(git_blame_hunk *hunk)
{
git__free((void*)hunk->orig_path);
git_signature_free(hunk->final_signature);
git_signature_free(hunk->orig_signature);
git__free(hunk);
}
......@@ -252,6 +255,7 @@ static git_blame_hunk* hunk_from_entry(git_blame__entry *e)
git_blame_hunk *h = new_hunk(
e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path);
git_oid_cpy(&h->final_commit_id, git_commit_id(e->suspect->commit));
h->final_signature = git_signature_dup(git_commit_author(e->suspect->commit));
h->boundary = e->is_boundary ? 1 : 0;
return h;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment