Ensure all deltas were resolved in a pack

If a pack uses OFS_DELTA only (e.g. its an initial push to a
repository) and PackParser's implementation is broken such that the
delta chain that hangs below a particular object offset is empty, the
entryCount won't match the expected objectCount. Fail fast rather
than claiming the stream was parsed correctly.

The current implementation is not broken as described above.  I broke
the code when I implemented my own new subclass of PackParser (which
incorrectly mucked with the object offset information), leading me to
discover this consistency check was missing.

Change-Id: I07540f0ae1144ef6f3bda48774dbdefb8876e1d3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
This commit is contained in:
Shawn O. Pearce 2011-01-18 17:14:15 -08:00 committed by Chris Aniszczyk
parent 1bf0c3cdb1
commit d62350d907
1 changed files with 6 additions and 0 deletions

View File

@ -409,6 +409,12 @@ public PackLock parse(ProgressMonitor progress) throws IOException {
}
resolveDeltasWithExternalBases(progress);
if (entryCount < objectCount) {
throw new IOException(MessageFormat.format(JGitText
.get().packHasUnresolvedDeltas,
(objectCount - entryCount)));
}
}
}