Add cat-file example and increase const use in API

This adds an example implementation that emulates git cat-file.
It is a convenient and relatively simple example of getting data
out of a repository.

Implementing this also revealed that there are a number of APIs
that are still not using const pointers to objects that really
ought to be.  The main cause of this is that `git_vector_bsearch`
may need to call `git_vector_sort` before doing the search, so a
const pointer to the vector is not allowed.  However, for tree
objects, with a little care, we can ensure that the vector of
tree entries is always sorted and allow lookups to take a const
pointer.  Also, the missing const in commit objects just looks
like an oversight.
Make examples/diff.c compile vs threadsafe library
Ensure reuc vector is always valid

In theory, if there was a problem reading the REUC data, the
read_reuc() routine could have left uninitialized and invalid
data in the git_index vector.  This moves the line that inserts a
new entry into the vector down to the bottom of the routine so we
know all the content is already valid.  Also, per @linquize, this
uses calloc to ensure no uninitialized data.
Merge pull request #1591 from arrbee/reorder-reuc-read-for-safety

Ensure reuc vector is always valid
Merge pull request #1590 from arrbee/examples-like-git

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