Add callback to git_objects_table

This adds create and free callback to the git_objects_table so
that more of the creation and destruction of objects can be table
driven instead of using switch statements.  This also makes the
semantics of certain object creation functions consistent so that
we can make better use of function pointers.  This also fixes a
theoretical error case where an object allocation fails and we
end up storing NULL into the cache.
Simplify object table parse functions

This unifies the object parse functions into one signature that
takes an odb_object.
clean up tree pointer casting
Merge pull request #1463 from arrbee/new-cache-free-callback

Add callbacks for object free/parse