summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColby Ranger <cranger@google.com>2013-09-19 14:33:13 -0700
committerColby Ranger <cranger@google.com>2013-09-19 14:53:01 -0700
commit570bba5e7acb08df827655c31045bfe9cde9d856 (patch)
treeef4ff39f859c19e08ad5a13fb52767faa418e9ff
parent801aac579e51cbb757fa16b11a89275cc2972c70 (diff)
downloadjgit-570bba5e7acb08df827655c31045bfe9cde9d856.tar.gz
jgit-570bba5e7acb08df827655c31045bfe9cde9d856.zip
Ignore bitmap indexes that do not match the pack checksum
If `git gc` creates a new pack with the same file name, the pack checksum may not match that in the .bitmap. Fix the PackFile implementaion to silently ignore invalid bitmap indexes. Fixes Issue https://code.google.com/p/gerrit/issues/detail?id=2131 Change-Id: I378673c00de32385ba90f4b639cb812f9574a216
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
index b52d3f70a4..5e1e2b1a38 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
@@ -121,6 +121,8 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
private volatile boolean invalid;
+ private boolean invalidBitmap;
+
private byte[] packChecksum;
private PackIndex loadedIdx;
@@ -1057,19 +1059,17 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
}
synchronized PackBitmapIndex getBitmapIndex() throws IOException {
- if (invalid)
+ if (invalid || invalidBitmap)
return null;
if (bitmapIdx == null && hasExt(BITMAP_INDEX)) {
final PackBitmapIndex idx = PackBitmapIndex.open(
extFile(BITMAP_INDEX), idx(), getReverseIdx());
- if (packChecksum == null)
- packChecksum = idx.packChecksum;
- else if (!Arrays.equals(packChecksum, idx.packChecksum))
- throw new PackMismatchException(
- JGitText.get().packChecksumMismatch);
-
- bitmapIdx = idx;
+ // At this point, idx() will have set packChecksum.
+ if (Arrays.equals(packChecksum, idx.packChecksum))
+ bitmapIdx = idx;
+ else
+ invalidBitmap = true;
}
return bitmapIdx;
}