diff options
author | Ben Straub <bs@github.com> | 2014-01-08 19:43:31 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2014-01-08 19:43:31 -0800 |
commit | 426d8456ea979cfae401ced2f88cc811a8b8264a (patch) | |
tree | 7c58d3ab42752ba14e6511b156ab5cc38628a4eb | |
parent | cc3d961bd949f11ad90fd4bb513bbc089f6cb61a (diff) | |
parent | b92b434f5a240a8c149bcf86bbcd1743cd873bcf (diff) | |
download | libgit2-426d8456ea979cfae401ced2f88cc811a8b8264a.tar.gz |
Merge pull request #2033 from xtao/blame_orig_commit
Add orig_commit.
-rw-r--r-- | src/blame.c | 6 | ||||
-rw-r--r-- | tests/blame/blame_helpers.c | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/blame.c b/src/blame.c index a1357415a..45f55ed14 100644 --- a/src/blame.c +++ b/src/blame.c @@ -242,7 +242,7 @@ static int index_blob_lines(git_blame *blame) git_off_t len = blame->final_buf_size; int num = 0, incomplete = 0, bol = 1; size_t *i; - + if (len && buf[len-1] != '\n') incomplete++; /* incomplete line at the end */ while (len--) { @@ -263,13 +263,15 @@ static int index_blob_lines(git_blame *blame) blame->num_lines = num + incomplete; return blame->num_lines; } - + 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)); + git_oid_cpy(&h->orig_commit_id, git_commit_id(e->suspect->commit)); h->final_signature = git_signature_dup(git_commit_author(e->suspect->commit)); + h->orig_signature = git_signature_dup(git_commit_author(e->suspect->commit)); h->boundary = e->is_boundary ? 1 : 0; return h; } diff --git a/tests/blame/blame_helpers.c b/tests/blame/blame_helpers.c index d64bb5c4c..56240dbde 100644 --- a/tests/blame/blame_helpers.c +++ b/tests/blame/blame_helpers.c @@ -48,6 +48,9 @@ void check_blame_hunk_index(git_repository *repo, git_blame *blame, int idx, actual, expected); } cl_assert_equal_s(actual, expected); + cl_assert_equal_i(git_oid_cmp(&hunk->final_commit_id, &hunk->orig_commit_id), 0); + + if (strcmp(hunk->orig_path, orig_path)) { hunk_message(idx, hunk, "has mismatched original path (got '%s', expected '%s')\n", hunk->orig_path, orig_path); |