pack: remove misleading comment
pack: do not repeat the same error message four times

Repeating this error message makes it harder to find out where we
actually are finding the error, and they don't really describe what
we're trying to do.
pack: unpack using a loop

We currently make use of recursive function calls to unpack an object,
resolving the deltas as we come back down the chain. This means that we
have unbounded stack growth as we look up objects in a pack.

This is now done in two steps: first we figure out what the dependency
chain is by looking up the delta bases until we reach a non-delta
object, pushing the information we need onto a stack and then we pop
from that stack and apply the deltas until there are no more left.

This version of the code does not make use of the delta base cache so it
is slower than what's in the mainline. A later commit will reintroduce
it.
pack: use a cache for delta bases when unpacking

Bring back the use of the delta base cache for unpacking objects. When
generating the delta chain, we stop when we find a delta base in the
pack's cache and use that as the starting point.
pack: make sure not to leak the dep chain
pack: preallocate a 64-element chain

Dependency chains are often large and require a few
reallocations. Allocate a 64-element chain before doing anything else to
avoid allocations during the loop.

This value comes from the stack-allocated one git uses. We still
allocate this on the heap, but it does help performance a little bit.
pack: simplify delta chain code

The switch makes the loop somewhat unwieldy. Let's assume it's fine and
perform the check when we're accessing the data.

This makes our code look a lot more like git's.
pack: expose a cached delta base directly

Instead of going through a special entry in the chain, let's pass it as
an output parameter.
pack: use stack allocation for smaller delta chains

This avoid allocating the array on the heap for relatively small
chains. The expected performance increase is sadly not really
noticeable.
pack: don't forget to cache the base object

The base object is a good cache candidate, so we shouldn't forget to add
it to the cache.
Merge pull request #2330 from libgit2/cmn/pack-unpack-loop

Make pack object lookup use loops