diff options
author | Xing Huang <xingkhuang@google.com> | 2024-03-12 16:24:10 -0500 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2024-03-12 22:55:56 +0000 |
commit | 631cbf59f3f8da23737694158ac79ca1c4e0a485 (patch) | |
tree | af9e1b10985c7098b106682c79d7cef04d218d51 /org.eclipse.jgit/src | |
parent | 1a654d3db6e5bd667dd5218a55084545538519a2 (diff) | |
download | jgit-631cbf59f3f8da23737694158ac79ca1c4e0a485.tar.gz jgit-631cbf59f3f8da23737694158ac79ca1c4e0a485.zip |
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 <xingkhuang@google.com>
Change-Id: If10c9b758fbe0498c7bd1e6ac1cda8869682f16d
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphLoader.java | 51 |
1 files 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. + * <p> + * 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; |