blame: add commit summary information

This commit is contained in:
Edward Thomson
2024-07-09 20:04:39 +01:00
parent 5378b80a9f
commit 49402cc614
2 changed files with 13 additions and 3 deletions

View File

@@ -204,6 +204,11 @@ typedef struct git_blame_hunk {
*/
git_signature *orig_committer;
/*
* The summary of the commit.
*/
const char *summary;
/**
* The 1 iff the hunk has been tracked to a boundary commit (the root,
* or the commit specified in git_blame_options.oldest_commit)

View File

@@ -80,7 +80,8 @@ static git_blame_hunk *new_hunk(
static void free_hunk(git_blame_hunk *hunk)
{
git__free((void*)hunk->orig_path);
git__free((char *)hunk->orig_path);
git__free((char *)hunk->summary);
git_signature_free(hunk->final_signature);
git_signature_free(hunk->final_committer);
git_signature_free(hunk->orig_signature);
@@ -107,7 +108,8 @@ static git_blame_hunk *dup_hunk(git_blame_hunk *hunk, git_blame *blame)
if (git_signature_dup(&newhunk->final_signature, hunk->final_signature) < 0 ||
git_signature_dup(&newhunk->final_committer, hunk->final_committer) < 0 ||
git_signature_dup(&newhunk->orig_signature, hunk->orig_signature) < 0 ||
git_signature_dup(&newhunk->orig_committer, hunk->orig_committer) < 0) {
git_signature_dup(&newhunk->orig_committer, hunk->orig_committer) < 0 ||
(newhunk->summary = git__strdup(hunk->summary)) == NULL) {
free_hunk(newhunk);
return NULL;
}
@@ -338,6 +340,7 @@ static int index_blob_lines(git_blame *blame)
static git_blame_hunk *hunk_from_entry(git_blame__entry *e, git_blame *blame)
{
const char *summary;
git_blame_hunk *h = new_hunk(
e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path,
blame);
@@ -353,7 +356,9 @@ static git_blame_hunk *hunk_from_entry(git_blame__entry *e, git_blame *blame)
git_commit_committer_with_mailmap(
&h->final_committer, e->suspect->commit, blame->mailmap) < 0 ||
git_signature_dup(&h->orig_signature, h->final_signature) < 0 ||
git_signature_dup(&h->orig_committer, h->final_committer) < 0) {
git_signature_dup(&h->orig_committer, h->final_committer) < 0 ||
(summary = git_commit_summary(e->suspect->commit)) == NULL ||
(h->summary = git__strdup(summary)) == NULL) {
free_hunk(h);
return NULL;
}