aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2016-06-01 17:07:19 -0400
committerDave Borowitz <dborowitz@google.com>2016-06-01 17:21:33 -0400
commit0d6ba84065b3281d2e3c3cf8251b7679cbc83488 (patch)
tree5492f830d9a7362ada48755d115cdc28d64201fa /org.eclipse.jgit
parent525baa1213097aa8635d846ce024635b1f33931a (diff)
downloadjgit-0d6ba84065b3281d2e3c3cf8251b7679cbc83488.tar.gz
jgit-0d6ba84065b3281d2e3c3cf8251b7679cbc83488.zip
DfsInserter: Optionally disable existing object check
When using a DfsInserter for high-throughput insertion of many objects (analogous to git-fast-import), we don't necessarily want to do a random object lookup for each. It'll be faster from the inserter's perspective to insert the duplicate objects and let a later GC handle the deduplication. Change-Id: Ic97f5f01657b4525f157e6df66023f1f07fc1851
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java12
1 files changed, 11 insertions, 1 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 f5673e83d1..3e8deac0f0 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
@@ -106,6 +106,7 @@ public class DfsInserter extends ObjectInserter {
DfsPackDescription packDsc;
PackStream packOut;
private boolean rollback;
+ private boolean checkExisting = true;
/**
* Initialize a new inserter.
@@ -117,6 +118,15 @@ public class DfsInserter extends ObjectInserter {
this.db = db;
}
+ /**
+ * @param check
+ * if 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;
}
@@ -138,7 +148,7 @@ public class DfsInserter extends ObjectInserter {
if (objectMap != null && objectMap.contains(id))
return id;
// Ignore unreachable (garbage) objects here.
- if (db.has(id, true))
+ if (checkExisting && db.has(id, true))
return id;
long offset = beginObject(type, len);