Add cat-file to examples (with some public API improvements)

This adds an implementation of `cat-file` to the examples directory that I wrote up when trying to chase down some potential issues in handling repository data. It turned out that everything was fine, but I thought the cat-file example might be interesting to people. It is not a lot of code.

While I was working on it, however, I found that there were a few public APIs that were not taking const pointers to objects that I really felt should be taking const pointers. It turns out that, in the tree API at least, the reason for this is that we want to do a `git_vector_bsearch` on the tree entries and that call thinks that it may need to call `git_vector_sort` so const pointers are disallowed. However, with a little care, we can make sure that the tree object is always sorted and push const-ness back into the API. I did that (asserting that the vector is already sorted and then making the public API take a const pointer to the tree). Also, there were a couple of non-const commit APIs, but I think that was just an oversight which I also corrected.

Lastly, I've been building with THREADSAFE on my local machine and I found that the `diff` example wouldn't run against a threadsafe build of the library, so I fixed that too.