summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-07-09 07:57:47 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-07-09 19:02:54 -0700
commit6730f9e3c830d997d1731bf36414e626bda42ad8 (patch)
tree34037dafbf67c2beec200cfcb0cb190a16c8950c
parent823e9a972100ad197fcb40efb37e1ca33f4bdb01 (diff)
downloadjgit-6730f9e3c830d997d1731bf36414e626bda42ad8.tar.gz
jgit-6730f9e3c830d997d1731bf36414e626bda42ad8.zip
Configure core.bigFileThreshold into PackWriter
C Git's fast-import uses this to determine the maximum file size that it tries to delta compress, anything equal to or above this setting is stored with as a whole object with simple deflate. Define the configuration so we can use it later. Change-Id: Iea46e787d019a1b6c51135cc73d7688a02e207f5 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java28
2 files changed, 31 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java
index b3d140a8e1..bd506a7591 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java
@@ -65,12 +65,15 @@ class PackConfig {
final int indexVersion;
+ final long bigFileThreshold;
+
private PackConfig(Config rc) {
deltaWindow = rc.getInt("pack", "window", PackWriter.DEFAULT_DELTA_SEARCH_WINDOW_SIZE);
deltaWindowMemory = rc.getLong("pack", null, "windowmemory", 0);
deltaDepth = rc.getInt("pack", "depth", PackWriter.DEFAULT_MAX_DELTA_DEPTH);
compression = compression(rc);
indexVersion = rc.getInt("pack", "indexversion", 2);
+ bigFileThreshold = rc.getLong("core", null, "bigfilethreshold", PackWriter.DEFAULT_BIG_FILE_THRESHOLD);
}
private static int compression(Config rc) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
index 25e2bea1ab..7cf8d2a26e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
@@ -172,6 +172,8 @@ public class PackWriter {
*/
public static final int DEFAULT_DELTA_SEARCH_WINDOW_SIZE = 10;
+ static final long DEFAULT_BIG_FILE_THRESHOLD = 50 * 1024 * 1024;
+
private static final int PACK_VERSION_GENERATED = 2;
@SuppressWarnings("unchecked")
@@ -216,6 +218,8 @@ public class PackWriter {
private int indexVersion;
+ private long bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD;
+
private boolean thin;
private boolean ignoreMissingUninteresting = true;
@@ -269,6 +273,7 @@ public class PackWriter {
maxDeltaDepth = pc.deltaDepth;
compressionLevel = pc.compression;
indexVersion = pc.indexVersion;
+ bigFileThreshold = pc.bigFileThreshold;
}
private static Config configOf(final Repository repo) {
@@ -455,6 +460,29 @@ public class PackWriter {
deltaSearchWindowSize = objectCount;
}
+ /**
+ * Get the maximum file size that will be delta compressed.
+ * <p>
+ * Files bigger than this setting will not be delta compressed, as they are
+ * more than likely already highly compressed binary data files that do not
+ * delta compress well, such as MPEG videos.
+ *
+ * @return the configured big file threshold.
+ */
+ public long getBigFileThreshold() {
+ return bigFileThreshold;
+ }
+
+ /**
+ * Set the maximum file size that should be considered for deltas.
+ *
+ * @param bigFileThreshold
+ * the limit, in bytes.
+ */
+ public void setBigFileThreshold(long bigFileThreshold) {
+ this.bigFileThreshold = bigFileThreshold;
+ }
+
/** @return true if this writer is producing a thin pack. */
public boolean isThin() {
return thin;