aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphLoader.java22
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java29
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileCommitGraph.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java22
6 files changed, 102 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphLoader.java
index d6310e0a85..867d522e08 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphLoader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphLoader.java
@@ -27,9 +27,12 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.NB;
+import org.eclipse.jgit.util.SystemReader;
import org.eclipse.jgit.util.io.SilentFileInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -139,6 +142,17 @@ public class CommitGraphLoader {
chunks.add(new ChunkSegment(id, offset));
}
+ boolean readChangedPathFilters;
+ try {
+ readChangedPathFilters = SystemReader.getInstance()
+ .getJGitConfig()
+ .getBoolean(ConfigConstants.CONFIG_COMMIT_GRAPH_SECTION,
+ ConfigConstants.CONFIG_KEY_READ_CHANGED_PATHS, false);
+ } catch (ConfigInvalidException e) {
+ // Use the default value if, for some reason, the config couldn't be read.
+ readChangedPathFilters = false;
+ }
+
CommitGraphBuilder builder = CommitGraphBuilder.builder();
for (int i = 0; i < numberOfChunks; i++) {
long chunkOffset = chunks.get(i).offset;
@@ -167,10 +181,14 @@ public class CommitGraphLoader {
builder.addExtraList(buffer);
break;
case CHUNK_ID_BLOOM_FILTER_INDEX:
- builder.addBloomFilterIndex(buffer);
+ if (readChangedPathFilters) {
+ builder.addBloomFilterIndex(buffer);
+ }
break;
case CHUNK_ID_BLOOM_FILTER_DATA:
- builder.addBloomFilterData(buffer);
+ if (readChangedPathFilters) {
+ builder.addBloomFilterData(buffer);
+ }
break;
default:
LOG.warn(MessageFormat.format(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java
index eb9dfb4d9c..9d1c33959f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java
@@ -73,6 +73,8 @@ public class CommitGraphWriter {
private final GraphCommits graphCommits;
+ private final boolean generateChangedPathFilters;
+
/**
* Create commit-graph writer for these commits.
*
@@ -80,8 +82,22 @@ public class CommitGraphWriter {
* the commits which will be writen to the commit-graph.
*/
public CommitGraphWriter(@NonNull GraphCommits graphCommits) {
+ this(graphCommits, false);
+ }
+
+ /**
+ * Create commit-graph writer for these commits.
+ *
+ * @param graphCommits
+ * the commits which will be writen to the commit-graph.
+ * @param generateChangedPathFilters
+ * whether changed path filters are generated
+ */
+ public CommitGraphWriter(@NonNull GraphCommits graphCommits,
+ boolean generateChangedPathFilters) {
this.graphCommits = graphCommits;
this.hashsz = OBJECT_ID_LENGTH;
+ this.generateChangedPathFilters = generateChangedPathFilters;
}
/**
@@ -140,11 +156,14 @@ public class CommitGraphWriter {
chunks.add(new ChunkHeader(CHUNK_ID_EXTRA_EDGE_LIST,
graphCommits.getExtraEdgeCnt() * 4));
}
- BloomFilterChunks bloomFilterChunks = computeBloomFilterChunks(stats);
- chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_INDEX,
- bloomFilterChunks.index));
- chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_DATA,
- bloomFilterChunks.data));
+ if (generateChangedPathFilters) {
+ BloomFilterChunks bloomFilterChunks = computeBloomFilterChunks(
+ stats);
+ chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_INDEX,
+ bloomFilterChunks.index));
+ chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_DATA,
+ bloomFilterChunks.data));
+ }
return chunks;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
index 9f415782fa..8cb94dcf4b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
@@ -81,6 +81,8 @@ public class DfsGarbageCollector {
private ReftableConfig reftableConfig;
private boolean convertToReftable = true;
private boolean writeCommitGraph;
+
+ private boolean writeBloomFilter;
private boolean includeDeletes;
private long reftableInitialMinUpdateIndex = 1;
private long reftableInitialMaxUpdateIndex = 1;
@@ -299,6 +301,20 @@ public class DfsGarbageCollector {
}
/**
+ * Toggle bloom filter generation.
+ * <p>
+ * False by default.
+ *
+ * @param enable
+ * Whether bloom filter generation is enabled
+ * @return {@code this}
+ */
+ public DfsGarbageCollector setWriteBloomFilter(boolean enable) {
+ writeBloomFilter = enable;
+ return this;
+ }
+
+ /**
* Create a single new pack file containing all of the live objects.
* <p>
* This method safely decides which packs can be expired after the new pack
@@ -774,7 +790,8 @@ public class DfsGarbageCollector {
RevWalk pool = new RevWalk(ctx)) {
GraphCommits gcs = GraphCommits.fromWalk(pm, allTips, pool);
CountingOutputStream cnt = new CountingOutputStream(out);
- CommitGraphWriter writer = new CommitGraphWriter(gcs);
+ CommitGraphWriter writer = new CommitGraphWriter(gcs,
+ writeBloomFilter);
writer.write(pm, cnt);
pack.addFileExt(COMMIT_GRAPH);
pack.setFileSize(COMMIT_GRAPH, cnt.getCount());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileCommitGraph.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileCommitGraph.java
index 44429a7786..5172963e2e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileCommitGraph.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileCommitGraph.java
@@ -108,7 +108,8 @@ public class FileCommitGraph {
// commit-graph file was not modified
return this;
}
- return new GraphSnapshot(file, FileSnapshot.save(file), open(file));
+ return new GraphSnapshot(file, FileSnapshot.save(file),
+ open(file));
}
private static CommitGraph open(File file) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index ace0d7be7b..144ff4aa04 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -135,6 +135,8 @@ public class GC {
private static final int DEFAULT_AUTOLIMIT = 6700;
+ private static final boolean DEFAULT_WRITE_BLOOM_FILTER = false;
+
private static final boolean DEFAULT_WRITE_COMMIT_GRAPH = false;
private static volatile ExecutorService executor;
@@ -959,7 +961,8 @@ public class GC {
File tmpFile = null;
try (RevWalk walk = new RevWalk(repo)) {
CommitGraphWriter writer = new CommitGraphWriter(
- GraphCommits.fromWalk(pm, wants, walk));
+ GraphCommits.fromWalk(pm, wants, walk),
+ shouldWriteBloomFilter());
tmpFile = File.createTempFile("commit_", //$NON-NLS-1$
COMMIT_GRAPH.getTmpExtension(),
repo.getObjectDatabase().getInfoDirectory());
@@ -1011,7 +1014,7 @@ public class GC {
/**
* If {@code true}, will rewrite the commit-graph file when gc is run.
*
- * @return true if commit-graph should be writen. Default is {@code false}.
+ * @return true if commit-graph should be written. Default is {@code false}.
*/
boolean shouldWriteCommitGraphWhenGc() {
return repo.getConfig().getBoolean(ConfigConstants.CONFIG_GC_SECTION,
@@ -1019,6 +1022,17 @@ public class GC {
DEFAULT_WRITE_COMMIT_GRAPH);
}
+ /**
+ * If {@code true}, generates bloom filter in the commit-graph file.
+ *
+ * @return true if bloom filter should be written. Default is {@code false}.
+ */
+ boolean shouldWriteBloomFilter() {
+ return repo.getConfig().getBoolean(ConfigConstants.CONFIG_GC_SECTION,
+ ConfigConstants.CONFIG_KEY_WRITE_CHANGED_PATHS,
+ DEFAULT_WRITE_BLOOM_FILTER);
+ }
+
private static boolean isHead(Ref ref) {
return ref.getName().startsWith(Constants.R_HEADS);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
index 621db89f66..7776b00625 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -109,6 +109,7 @@ public final class ConfigConstants {
/**
* The "fetch" section
+ *
* @since 3.3
*/
public static final String CONFIG_FETCH_SECTION = "fetch";
@@ -947,4 +948,25 @@ public final class ConfigConstants {
* @since 5.13.2
*/
public static final String CONFIG_KEY_PRUNE_PRESERVED = "prunepreserved";
+
+ /**
+ * The "commitGraph" section
+ *
+ * @since 6.7
+ */
+ public static final String CONFIG_COMMIT_GRAPH_SECTION = "commitGraph";
+
+ /**
+ * The "writeChangedPaths" key
+ *
+ * @since 6.7
+ */
+ public static final String CONFIG_KEY_WRITE_CHANGED_PATHS = "writeChangedPaths";
+
+ /**
+ * The "readChangedPaths" key
+ *
+ * @since 6.7
+ */
+ public static final String CONFIG_KEY_READ_CHANGED_PATHS = "readChangedPaths";
}