libgit2/libgit2 — pull request #1847 by arrbee (2013-09-11 23:54:30+00:00)
Title: Alternative proposal for filter API

This is an alternative proposal to PR #1683

Like that PR, this adds a public API for filters in `include/git2/filter.h` and a plug-in API for filters in `include/git2/sys/filter.h`. The API here is somewhat different than what is proposed in that PR, although not too different in the end.

In addition to updating the default internal way of finding and applying filters, this adds a simple new public API to get the content of a blob in filtered form `git_blob_filtered_content` and a very granular API for applying filters to data (via `git_filter_list_load` and the various forms of `git_filter_list_apply_...`).

As part of these new public APIs, I felt like it was time to create a public `git_buffer` object that could be used for passing data into and out of filters and other related calls. Writing this code with a public `git_buffer` is awkward.

As a test of the filter writing APIs, this adds the "ident" filter to libgit2. It wasn't too hard to write, which makes me feel like the API is not too bad.

Because the filter registry is a global list which needs to be cleaned up at shutdown time and because this is now the third or fourth global shutdown routine, I added a very simply list of global shutdown callbacks to `src/global.c` and converted all of the various shutdown routines to use that. It is terribly dumb, but I think it will be fine for now.

- [x] Write enough for an interesting discussion
- [ ] Moar tests