Read the pack index header to perform automatic version detection
In pack index v2 the first 8 bytes of the file represent a header
with a magic signature (first 4 bytes) and version number (last 4
bytes). In pack index v1 this header does not exist, the first 8
bytes of the file are part of the fan-out table.
This refactoring reads the first 8 bytes and then passes them down
into PackIndexV1 along with the open InputStream, letting it finish
the reading process on its own. This does hurt our performance on
opening a version 1 index file as we now need to perform 258 system
calls to read the file content. Not much we can do about it if we
want to avoid buffering large amounts of data.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>