tests: plug a couple of leaks
pack: introduce a delta base cache

Many delta bases are re-used. Cache them to avoid inflating the same
data repeatedly.

This version doesn't limit the amount of entries to store, so it can
end up using a considerable amound of memory.
pack: refcount entries and add a mutex around cache access
pack: abstract out the cache into its own functions
pack: limit the amount of memory the base delta cache can use

Currently limited to 16MB (like git) and to objects up to 1MB in
size.
pack: packfile_free -> git_packfile_free and use it in the indexers

It turns out the indexers have been ignoring the pack's free function
and leaking data. Plug that.