Allow PackFile to lazily load its PackIndex on first demand
Repositories which contain several pack files may have a very large
historical pack holding the bulk of the project data, and a much
smaller more recent pack holding current data. In such cases we
may be able to answer queries entirely by reading the recent pack
index, and never reading the larger historical index. Since JGit
reads the entire index into memory, avoiding reading the larger
index can save some time on short uses of a Repository.
This change only sets up the lazy loading of the index. Because
the packs aren't sorted by newest-to-oldest in Repository we are
still very likely to demand load packs we didn't need to examine.
This change also opens the door for potentially releasing one or
more PackIndex objects when memory gets low, but doesn't actually
implement any sort of soft reference semantics.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>