Have diff blob to buffer share code (and add tests)

This takes the work in PR #1170 and updates it to share implementation internals between `git_diff_blobs` and `git_diff_blob_to_buffer` which are essentially the same function. Also, this adds tests for the `git_diff_blob_to_buffer` API.

I did also add some extra `const` to both of these APIs and a couple of other APIs (like `git_blob_rawcontent`) that were called internally. I had to jump through a couple of hoops to make sure that all worked, but I think it's for the best.

This includes the commit from PR #1170 (as is) so it can be merged instead of that PR, I believe.