Read the pack index header to perform automatic version detection
commit199e3481dc1df7e7bec9ff19f2b60ae95e52deff
authorShawn O. Pearce <spearce@spearce.org>
Thu, 6 Mar 2008 00:35:34 +0000 (5 19:35 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 7 Apr 2008 03:25:59 +0000 (6 23:25 -0400)
tree77216c717098f842b12057dbd7b5620182a1fa6b
parent299e0ac169d7534c2875cd05b6e19e71f5f0fe69
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>
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV1.java