]> source.dussan.org Git - jgit.git/commitdiff
PackBitmapIndex: hide packChecksum behind getter 14/1184614/1
authorSam Delmerico <delmerico@google.com>
Tue, 19 Mar 2024 00:14:24 +0000 (17:14 -0700)
committerSam Delmerico <delmerico@google.com>
Tue, 19 Mar 2024 00:14:24 +0000 (17:14 -0700)
This allows more flexibility in overriding the PackBitmapIndex and also
allows us to turn PackBitmapIndex into an interface in
https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1178201.

Change-Id: I3be611fad67ff38b308c0052a04149f1497858ae

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexV1.java

index 212dbb20aa41fa1aa7bbb39b16de8021e4a1af54..f87329ccc2b94a5b872ed35980cdc9c4cf1d488c 100644 (file)
@@ -1154,7 +1154,7 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
                        PackBitmapIndex idx = PackBitmapIndex.open(bitmapIdxFile, idx(),
                                        getReverseIdx());
                        // At this point, idx() will have set packChecksum.
-                       if (Arrays.equals(packChecksum, idx.packChecksum)) {
+                       if (Arrays.equals(packChecksum, idx.getPackChecksum())) {
                                bitmapIdx = optionally(idx);
                                return idx;
                        }
index def4f3dc11178d099e3bb5ee6a7539a60af96060..affd2c07614ae0b748ec9f4ea8e392d162d1fb99 100644 (file)
@@ -132,8 +132,14 @@ public abstract class PackBitmapIndex {
                                reverseIndexSupplier, loadParallelRevIndex);
        }
 
-       /** Footer checksum applied on the bottom of the pack file. */
-       byte[] packChecksum;
+       /**
+        * Footer checksum applied on the bottom of the pack file.
+        *
+        * @return checksum as a byte array
+        */
+       byte[] getPackChecksum() {
+               return null;
+       }
 
        /**
         * Finds the position in the bitmap of the object.
index f2f24b39cb4f98301bb816bbde3c3a9d0abccc07..19608c1ce5d100eaa2f87fad62f31df16dfcf957 100644 (file)
@@ -46,6 +46,8 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
 
        private static final int MAX_XOR_OFFSET = 126;
 
+       private byte[] packChecksum;
+
        private static final ExecutorService executor = Executors
                        .newCachedThreadPool(new ThreadFactory() {
                                private final ThreadFactory baseFactory = Executors
@@ -269,6 +271,11 @@ class PackBitmapIndexV1 extends BasePackBitmapIndex {
                return getPackIndex().hashCode();
        }
 
+       @Override
+       public byte[] getPackChecksum() {
+               return this.packChecksum;
+       }
+
        PackIndex getPackIndex() {
                return packIndex;
        }