aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2025-05-06 11:25:45 -0700
committerIvan Frade <ifrade@google.com>2025-05-06 13:12:44 -0700
commitd0e7071b1b64d419546a81899a0b410953804c22 (patch)
tree4c63ad41b0681d280a5bd93647276c8995cad17d
parente74771cb962bdef344e6b87658e75c9aca07fee3 (diff)
downloadjgit-d0e7071b1b64d419546a81899a0b410953804c22.tar.gz
jgit-d0e7071b1b64d419546a81899a0b410953804c22.zip
DfsInserter: Remove checkExisting setter and parameter
We turned this off to debug something else and it created significantly bigger packs that spammed the storage. There is no reason to allow duplicates while inserting in a pack, so lets remove completely the option. The setter is not used and the variable is always true. Change-Id: I978049dce30c33b7aa650d3ddef9430cbef764fa
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java16
2 files changed, 6 insertions, 19 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
index 0b558edf2c..49f399c38c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
@@ -214,7 +214,7 @@ public class DfsInserterTest {
}
@Test
- public void testNoCheckExisting() throws IOException {
+ public void testNoDuplicates() throws IOException {
byte[] contents = Constants.encode("foo");
ObjectId fooId;
try (ObjectInserter ins = db.newObjectInserter()) {
@@ -224,21 +224,20 @@ public class DfsInserterTest {
assertEquals(1, db.getObjectDatabase().listPacks().size());
try (ObjectInserter ins = db.newObjectInserter()) {
- ((DfsInserter) ins).checkExisting(false);
+ ins.insert(Constants.OBJ_BLOB, Constants.encode("bar"));
assertEquals(fooId, ins.insert(Constants.OBJ_BLOB, contents));
ins.flush();
}
assertEquals(2, db.getObjectDatabase().listPacks().size());
- // Verify that we have a foo in both INSERT packs.
+ // Newer packs are first. Verify that foo is only in the second pack
try (DfsReader reader = new DfsReader(db.getObjectDatabase())) {
DfsPackFile packs[] = db.getObjectDatabase().getPacks();
-
assertEquals(2, packs.length);
DfsPackFile p1 = packs[0];
assertEquals(PackSource.INSERT,
p1.getPackDescription().getPackSource());
- assertTrue(p1.hasObject(reader, fooId));
+ assertFalse(p1.hasObject(reader, fooId));
DfsPackFile p2 = packs[1];
assertEquals(PackSource.INSERT,
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 16315bf4f2..dd9e4b96a4 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
@@ -83,7 +83,6 @@ public class DfsInserter extends ObjectInserter {
DfsPackDescription packDsc;
PackStream packOut;
private boolean rollback;
- private boolean checkExisting = true;
/**
* Initialize a new inserter.
@@ -98,18 +97,6 @@ public class DfsInserter extends ObjectInserter {
ConfigConstants.CONFIG_KEY_MIN_BYTES_OBJ_SIZE_INDEX, -1);
}
- /**
- * Check existence
- *
- * @param check
- * if {@code false}, will write out possibly-duplicate objects
- * without first checking whether they exist in the repo; default
- * is true.
- */
- public void checkExisting(boolean check) {
- checkExisting = check;
- }
-
void setCompressionLevel(int compression) {
this.compression = compression;
}
@@ -130,8 +117,9 @@ public class DfsInserter extends ObjectInserter {
if (objectMap != null && objectMap.contains(id))
return id;
// Ignore unreachable (garbage) objects here.
- if (checkExisting && db.has(id, true))
+ if (db.has(id, true)) {
return id;
+ }
long offset = beginObject(type, len);
packOut.compress.write(data, off, len);