indexer: do multiple passes over the delta list

Though unusual, a packfile may contain a delta whose base is a delta
that comes later. In order index such a packfile, we must not give up
on the first failure to resolve a delta, but keep it around.

If there is a pass which makes no progress, this indicates that the
packfile is broken, so fail accordingly.
pack: move the object header function here
indexer: fix thin packs

When given an ODB from which to read objects, the indexer will attempt
to inject the missing bases at the end of the pack and update the
header and trailer to reflect the new contents.
net: advertise our support for fixing thin packs
indexer: inject one base at a time

There may be multiple deltas referencing the same base as well as OFS
deltas which rely on a thin delta. Deal with both at the same time by
injecting a single object and going back up to the main
delta-resolving loop.
indexer: clearer stats for thin packs

Don't increase the number of total objects, as it can produce
suprising progress output. The only addition compared to pre-thin is
the addition of local_objects to allow an output similar to git's
"completed with %d local objects".
examples: show used local objects in fetch

Show how many local objects were used to fix the thin pack in our fetch
example.
indexer: include the delta stats

The user is unable to derive the number of deltas in the pack, as that
would require them to capture the stats exactly in the moment between
download and final processing, which is abstracted away in the fetch.

Capture these numbers for the user and expose them in the progress
struct. The clone and fetch examples now also present this information
to the user.
Merge pull request #1891 from libgit2/cmn/fix-thin-packs

Add support for thin packs