Adjust for diff API changes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
diff --git a/src/blame.c b/src/blame.c
index e698d39..192e296 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -370,19 +370,15 @@ static bool hunk_is_bufferblame(git_blame_hunk *hunk)
static int buffer_hunk_cb(
const git_diff_delta *delta,
- const git_diff_range *range,
- const char *header,
- size_t header_len,
+ const git_diff_hunk *hunk,
void *payload)
{
git_blame *blame = (git_blame*)payload;
size_t wedge_line;
GIT_UNUSED(delta);
- GIT_UNUSED(header);
- GIT_UNUSED(header_len);
- wedge_line = (range->old_lines == 0) ? range->new_start : range->old_start;
+ wedge_line = (hunk->old_lines == 0) ? hunk->new_start : hunk->old_start;
blame->current_diff_line = wedge_line;
/* If this hunk doesn't start between existing hunks, split a hunk up so it does */
@@ -398,18 +394,15 @@ static int buffer_hunk_cb(
static int ptrs_equal_cmp(const void *a, const void *b) { return a<b ? -1 : a>b ? 1 : 0; }
static int buffer_line_cb(
const git_diff_delta *delta,
- const git_diff_range *range,
- char line_origin,
- const char *content,
- size_t content_len,
+ const git_diff_hunk *hunk,
+ const git_diff_line *line,
void *payload)
{
git_blame *blame = (git_blame*)payload;
GIT_UNUSED(delta);
- GIT_UNUSED(range);
- GIT_UNUSED(content);
- GIT_UNUSED(content_len);
+ GIT_UNUSED(hunk);
+ GIT_UNUSED(line);
#ifdef DO_DEBUG
{
@@ -418,7 +411,7 @@ static int buffer_line_cb(
}
#endif
- if (line_origin == GIT_DIFF_LINE_ADDITION) {
+ if (line->origin == GIT_DIFF_LINE_ADDITION) {
if (hunk_is_bufferblame(blame->current_hunk) &&
hunk_ends_at_or_before_line(blame->current_hunk, blame->current_diff_line)) {
/* Append to the current buffer-blame hunk */
@@ -433,7 +426,7 @@ static int buffer_line_cb(
blame->current_diff_line++;
}
- if (line_origin == GIT_DIFF_LINE_DELETION) {
+ if (line->origin == GIT_DIFF_LINE_DELETION) {
/* Trim the line from the current hunk; remove it if it's now empty */
size_t shift_base = blame->current_diff_line + blame->current_hunk->lines_in_hunk+1;
diff --git a/src/blame_git.c b/src/blame_git.c
index 2b02443..84ffa29 100644
--- a/src/blame_git.c
+++ b/src/blame_git.c
@@ -400,7 +400,7 @@ static git_blame__origin* find_origin(
git_blame__origin *origin)
{
git_blame__origin *porigin = NULL;
- git_diff_list *difflist = NULL;
+ git_diff *difflist = NULL;
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
git_tree *otree=NULL, *ptree=NULL;
@@ -427,7 +427,7 @@ static git_blame__origin* find_origin(
int i;
/* Generate a full diff between the two trees */
- git_diff_list_free(difflist);
+ git_diff_free(difflist);
diffopts.pathspec.count = 0;
if (0 != git_diff_tree_to_tree(&difflist, blame->repository, ptree, otree, &diffopts))
goto cleanup;
@@ -439,19 +439,19 @@ static git_blame__origin* find_origin(
/* Find one that matches */
for (i=0; i<(int)git_diff_num_deltas(difflist); i++) {
- const git_diff_delta *delta;
- git_diff_get_patch(NULL, &delta, difflist, i);
- if (git_vector_bsearch(NULL, &blame->paths, delta->new_file.path) != 0)
- continue;
-
- git_vector_insert_sorted(&blame->paths, (void*)git__strdup(delta->old_file.path),
- paths_on_dup);
- make_origin(&porigin, parent, delta->old_file.path);
+ const git_diff_delta *delta = git_diff_get_delta(difflist, i);
+
+ if (!git_vector_bsearch(NULL, &blame->paths, delta->new_file.path))
+ {
+ git_vector_insert_sorted(&blame->paths, (void*)git__strdup(delta->old_file.path),
+ paths_on_dup);
+ make_origin(&porigin, parent, delta->old_file.path);
+ }
}
}
cleanup:
- git_diff_list_free(difflist);
+ git_diff_free(difflist);
git_tree_free(otree);
git_tree_free(ptree);
return porigin;