Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2013-12-01 00:19:35 +0000
committerMatthias Sohn2013-12-06 13:27:42 +0000
commit2e0d178855dd1485c3a9022243c50e8917a909ee (patch)
treed010e18f5aafd85c95f431af43e0119a72038d5f /org.eclipse.jgit
parent162a5c4c89b289af3755a2f26843cdf908e93c50 (diff)
downloadjgit-2e0d178855dd1485c3a9022243c50e8917a909ee.tar.gz
jgit-2e0d178855dd1485c3a9022243c50e8917a909ee.tar.xz
jgit-2e0d178855dd1485c3a9022243c50e8917a909ee.zip
Add recursive variant of Config.getNames() methods
These methods allow to find all configuration entry names for a given section or section/subsection searching recursively through all base configurations of the given configuration. These methods are needed to calculate the names for the effective configuration of a git repository which combines the configuration entry names found in the repository, global and system configuration files Bug: 396659 Change-Id: Ie3731b5e877f8686aadad3f1a46b2e583ad3b7c6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java27
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java14
2 files changed, 40 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
index 81977d74ac..452ecddf42 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -528,6 +528,33 @@ public class Config {
}
/**
+ * @param section
+ * the section
+ * @param recursive
+ * if {@code true} recursively adds the names defined in all base
+ * configurations
+ * @return the list of names defined for this section
+ */
+ public Set<String> getNames(String section, boolean recursive) {
+ return getState().getNames(section, null, recursive);
+ }
+
+ /**
+ * @param section
+ * the section
+ * @param subsection
+ * the subsection
+ * @param recursive
+ * if {@code true} recursively adds the names defined in all base
+ * configurations
+ * @return the list of names defined for this subsection
+ */
+ public Set<String> getNames(String section, String subsection,
+ boolean recursive) {
+ return getState().getNames(section, subsection, recursive);
+ }
+
+ /**
* Obtain a handle to a parsed set of configuration values.
*
* @param <T>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java
index b7c4c64321..5ed129ed02 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java
@@ -97,6 +97,16 @@ class ConfigSnapshot {
}
Set<String> getNames(String section, String subsection) {
+ return getNames(section, subsection, false);
+ }
+
+ Set<String> getNames(String section, String subsection, boolean recursive) {
+ Map<String, String> m = getNamesInternal(section, subsection, recursive);
+ return new CaseFoldingSet(m);
+ }
+
+ private Map<String, String> getNamesInternal(String section,
+ String subsection, boolean recursive) {
List<ConfigLine> s = sorted();
int idx = find(s, section, subsection, ""); //$NON-NLS-1$
if (idx < 0)
@@ -113,7 +123,9 @@ class ConfigSnapshot {
if (!m.containsKey(l))
m.put(l, e.name);
}
- return new CaseFoldingSet(m);
+ if (recursive && baseState != null)
+ m.putAll(baseState.getNamesInternal(section, subsection, recursive));
+ return m;
}
String[] get(String section, String subsection, String name) {

Back to the top