From 631cbf59f3f8da23737694158ac79ca1c4e0a485 Mon Sep 17 00:00:00 2001 From: Xing Huang Date: Tue, 12 Mar 2024 16:24:10 -0500 Subject: [PATCH] CommitGraphLoader: receive readChangedPaths as parameter commitGraph.readChangedPaths controls the read of bloom filter chunks from commit graph. CommitGraphLoader uses SystemReader to read this conf, so it only sees its value when it is set in $XDG_CONFIG_HOME/jgit/config (and not, for example, in the repo config). Pass the readChangedPaths value to the method that reads the commit graph. Callers should read the value from the right configuration. This change is a noop, but allows to move callers to the new method progressively. Follow up changes will remove the previous method and its usages. Signed-off-by: Xing Huang Change-Id: If10c9b758fbe0498c7bd1e6ac1cda8869682f16d --- .../commitgraph/CommitGraphLoader.java | 51 +++++++++++++++---- 1 file changed, 40 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 867d522e08..7e9220dc0d 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 @@ -98,6 +98,46 @@ public class CommitGraphLoader { */ public static CommitGraph read(InputStream fd) throws CommitGraphFormatException, IOException { + + 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; + } + + return read(fd, readChangedPathFilters); + } + + /** + * Read an existing commit-graph file from a buffered stream. + *

+ * The format of the file will be automatically detected and a proper access + * implementation for that format will be constructed and returned to the + * caller. The file may or may not be held open by the returned instance. + * + * @param fd + * stream to read the commit-graph file from. The stream must be + * buffered as some small IOs are performed against the stream. + * The caller is responsible for closing the stream. + * + * @param readChangedPathFilters + * enable reading bloom filter chunks. + * + * @return a copy of the commit-graph file in memory + * @throws CommitGraphFormatException + * the commit-graph file's format is different from we expected. + * @throws java.io.IOException + * the stream cannot be read. + */ + public static CommitGraph read(InputStream fd, + boolean readChangedPathFilters) + throws CommitGraphFormatException, IOException { byte[] hdr = new byte[8]; IO.readFully(fd, hdr, 0, hdr.length); @@ -142,17 +182,6 @@ 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; -- 2.39.5