Validate the pack's footer checksum matches that in the index
commite81c49f24c5c316c07d56ca8a9d4ba821ed87ca8
authorShawn O. Pearce <spearce@spearce.org>
Thu, 12 Feb 2009 02:36:57 +0000 (11 18:36 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Wed, 18 Feb 2009 21:22:39 +0000 (18 22:22 +0100)
treeba88121c301692baf18e55ac2c3c6909416787b0
parentbba2664a778bc3ae716b19d698ff0c6fc74d45fe
Validate the pack's footer checksum matches that in the index

If the SHA-1 checksum of the entire pack content does not match the
checksum stored in the corresponding *.idx file we cannot use the
index, as the offsets recorded with it are most likely incorrect.

This situation can arise if another application repacks the pack
with different compression settings, but puts the same set of
objects into it.  The offsets are going to be different, but the
resulting pack file and index file names will be the same.  If we
had previously read the old index into memory, but the pack isn't
a match anymore, we can't safely access this pack.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndex.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV1.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackIndexV2.java