As is, this generates a full text diff for every item in the diff even though you don't use the majority of them. Instead, I think you probably want to iterate through the diff deltas and only get the text diffs (using the `git_diff_get_patch()` API) for the files that you actually are interested in. Something like:

```c
int error = 0;
size_t i, max_i = git_diff_num_deltas(diff);

for (i = 0; i < max_i; ++i) {
    git_diff_delta *delta;
    git_diff_patch *patch;

    /* just get the delta to see if we care about this entry */
    if ((error = git_diff_get_patch(NULL, &delta, diff, i)) < 0)
        break;

    /* try to look up filename in the list of paths */
    if (git_vector_search(NULL, &blame->paths, delta->new_file.path) != 0)
        continue;

    /* now that we know we're interested, generate the text diff */
    if ((error = git_diff_get_patch(&patch, &delta, diff, i)) < 0)
        break;

    /* code to process `patch` object with text diffs goes here */

    git_diff_patch_free(patch);
}
```

Then you can get rid of the `trivial_file_cb` completely and probably collapse the hunk and line callbacks into a single function that uses indexed access to read the `git_diff_patch`.

This will be significantly more efficient, I think.