aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkylezhao <kylezhao@tencent.com>2022-12-12 10:22:04 +0800
committerIvan Frade <ifrade@google.com>2022-12-16 10:21:09 -0500
commit7016e2ddaedef2434e9c5b728b268f41d81cd6a0 (patch)
tree2e6ba0c96dfdd15ac411afc74e06e2c22ceb7f1e
parent6ea36794d1eaa2b50f032b3f46c76b8c4f47a901 (diff)
downloadjgit-7016e2ddaedef2434e9c5b728b268f41d81cd6a0.tar.gz
jgit-7016e2ddaedef2434e9c5b728b268f41d81cd6a0.zip
CommitGraph: add core.commitGraph config
Change-Id: I3b5e735ebafba09ca18fd83da479c7950fa3ea8d Signed-off-by: kylezhao <kylezhao@tencent.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java24
3 files changed, 45 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index a85a4f49b6..8f9d105319 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -1581,6 +1581,20 @@ public class ConfigTest {
config.get(CommitConfig.KEY).getCommitTemplateContent(repo);
}
+ @Test
+ public void testCoreCommitGraphConfig() {
+ Config config = new Config();
+ assertFalse(config.get(CoreConfig.KEY).enableCommitGraph());
+
+ config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_COMMIT_GRAPH, true);
+ assertTrue(config.get(CoreConfig.KEY).enableCommitGraph());
+
+ config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_COMMIT_GRAPH, false);
+ assertFalse(config.get(CoreConfig.KEY).enableCommitGraph());
+ }
+
private static void assertValueRoundTrip(String value)
throws ConfigInvalidException {
assertValueRoundTrip(value, value);
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 203533d3a8..d0ec479149 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -892,4 +892,11 @@ public final class ConfigConstants {
* @since 6.5
*/
public static final String CONFIG_KEY_WRITE_COMMIT_GRAPH = "writeCommitGraph";
+
+ /**
+ * The "commitGraph" used by commit-graph feature
+ *
+ * @since 6.5
+ */
+ public static final String CONFIG_COMMIT_GRAPH = "commitGraph";
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
index f23c6e08d1..b1ace6e868 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
@@ -116,6 +116,13 @@ public class CoreConfig {
ALWAYS
}
+ /**
+ * Default value of commit graph enable option: {@value}
+ *
+ * @since 6.5
+ */
+ public static final boolean DEFAULT_COMMIT_GRAPH_ENABLE = false;
+
private final int compression;
private final int packIndexVersion;
@@ -126,6 +133,8 @@ public class CoreConfig {
private final String attributesfile;
+ private final boolean commitGraph;
+
/**
* Options for symlink handling
*
@@ -167,6 +176,9 @@ public class CoreConfig {
ConfigConstants.CONFIG_KEY_EXCLUDESFILE);
attributesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION,
null, ConfigConstants.CONFIG_KEY_ATTRIBUTESFILE);
+ commitGraph = rc.getBoolean(ConfigConstants.CONFIG_CORE_SECTION,
+ ConfigConstants.CONFIG_COMMIT_GRAPH,
+ DEFAULT_COMMIT_GRAPH_ENABLE);
}
/**
@@ -219,4 +231,16 @@ public class CoreConfig {
public String getAttributesFile() {
return attributesfile;
}
+
+ /**
+ * Whether to read the commit-graph file (if it exists) to parse the graph
+ * structure of commits. Default to
+ * {@value org.eclipse.jgit.lib.CoreConfig#DEFAULT_COMMIT_GRAPH_ENABLE}.
+ *
+ * @return whether to read the commit-graph file
+ * @since 6.5
+ */
+ public boolean enableCommitGraph() {
+ return commitGraph;
+ }
}