summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2024-02-22 14:15:10 -0800
committerIvan Frade <ifrade@google.com>2024-02-26 10:57:00 -0800
commit5c94dcc56e893e2d101fb55f9292f16905b86226 (patch)
treee92d6949952e686f22790888411690d8e1be291e /org.eclipse.jgit
parent049749558e340e1c34abd9b7bf08696c6fd99880 (diff)
downloadjgit-5c94dcc56e893e2d101fb55f9292f16905b86226.tar.gz
jgit-5c94dcc56e893e2d101fb55f9292f16905b86226.zip
DfsObjDatabase: Let object database instantiate DfsPackFiles
DfsPackfile used to have only one constructor and it is invoked from 3 locations. Now we can construct DfsPackFiles with different bitmap loaders, so it is helpful to concentrate the instantiation in one location. Create DfsPackFile instances in the object database. This let subclasses choose how to initialize those instances. Change-Id: Ibb2ad86865154b6e7f0d5d26e8f533e0b5586246
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java2
3 files changed, 20 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
index dfab7bab6f..a07d8416c4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
@@ -217,7 +217,7 @@ public class DfsInserter extends ObjectInserter {
db.commitPack(Collections.singletonList(packDsc), null);
rollback = false;
- DfsPackFile p = new DfsPackFile(cache, packDsc);
+ DfsPackFile p = db.createDfsPackFile(cache, packDsc);
if (index != null)
p.setPackIndex(index);
db.addPack(p);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
index 2375698303..9f6eb10256 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
@@ -592,7 +592,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
if (oldPack != null) {
newPacks.add(oldPack);
} else if (dsc.hasFileExt(PackExt.PACK)) {
- newPacks.add(new DfsPackFile(cache, dsc));
+ newPacks.add(createDfsPackFile(cache, dsc));
foundNew = true;
}
@@ -617,6 +617,23 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
newReftables.toArray(new DfsReftable[0]));
}
+ /**
+ * Create instances of DfsPackFile
+ *
+ * Implementors can decide to construct or wrap DfsPackFile in different
+ * ways.
+ *
+ * @param cache
+ * block cache
+ * @param dsc
+ * pack description
+ * @return the dfs packfile
+ */
+ protected DfsPackFile createDfsPackFile(DfsBlockCache cache,
+ DfsPackDescription dsc) {
+ return new DfsPackFile(cache, dsc);
+ }
+
private static Map<DfsPackDescription, DfsPackFile> packMap(PackList old) {
Map<DfsPackDescription, DfsPackFile> forReuse = new HashMap<>();
for (DfsPackFile p : old.packs) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
index a38ce91ccd..b19f65c69b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
@@ -126,7 +126,7 @@ public class DfsPackParser extends PackParser {
objdb.commitPack(Collections.singletonList(packDsc), null);
rollback = false;
- DfsPackFile p = new DfsPackFile(blockCache, packDsc);
+ DfsPackFile p = objdb.createDfsPackFile(blockCache, packDsc);
p.setBlockSize(blockSize);
if (packIndex != null)
p.setPackIndex(packIndex);