aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorAnna Papitto <annapapitto@google.com>2023-07-14 12:19:27 -0700
committerAnna Papitto <annapapitto@google.com>2023-07-18 15:19:26 -0700
commitf196c7a0e838becff12d9a3ea922398cf8c9d3be (patch)
treec83210a2c95724f24fb54b8edec91043d7a820f7 /org.eclipse.jgit
parent2eba4e5b41c299d82e5aa0b974a1f039997ecf6e (diff)
downloadjgit-f196c7a0e838becff12d9a3ea922398cf8c9d3be.tar.gz
jgit-f196c7a0e838becff12d9a3ea922398cf8c9d3be.zip
Pack: open reverse index from file if present
The reverse index for a pack is still always computed if needed, which is slower than parsing it from a file. Supply the file path where the reverse index file might be so that it parsed instead of computed if the file is present. Change-Id: I8c60d970fd587341dfb2763fb87f1c586279f2a5 Signed-off-by: Anna Papitto <annapapitto@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
index 8d9fe23ae5..2b5586a2ce 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
@@ -14,6 +14,7 @@ package org.eclipse.jgit.internal.storage.file;
import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
import static org.eclipse.jgit.internal.storage.pack.PackExt.KEEP;
+import static org.eclipse.jgit.internal.storage.pack.PackExt.REVERSE_INDEX;
import java.io.EOFException;
import java.io.File;
@@ -1150,8 +1151,15 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
}
private synchronized PackReverseIndex getReverseIdx() throws IOException {
- if (reverseIdx == null)
- reverseIdx = PackReverseIndexFactory.computeFromIndex(idx());
+ if (invalid) {
+ throw new PackInvalidException(packFile, invalidatingCause);
+ }
+ if (reverseIdx == null) {
+ PackFile reverseIndexFile = packFile.create(REVERSE_INDEX);
+ reverseIdx = PackReverseIndexFactory.openOrCompute(reverseIndexFile,
+ getObjectCount(), () -> getIndex());
+ reverseIdx.verifyPackChecksum(getPackFile().getPath());
+ }
return reverseIdx;
}