aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java47
2 files changed, 47 insertions, 14 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 16db717032..d26b7fd17d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -129,9 +129,21 @@ public class Config {
}
/**
+ * Retrieves this config's base config.
+ *
+ * @return the base configuration of this config.
+ *
+ * @since 5.5.2
+ */
+ public Config getBaseConfig() {
+ return baseConfig;
+ }
+
+ /**
* Check if a given string is the "missing" value.
*
- * @param value string to be checked.
+ * @param value
+ * string to be checked.
* @return true if the given string is the "missing" value.
* @since 5.4
*/
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
index b80ffb51b5..a2253bc118 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
@@ -288,20 +288,16 @@ public abstract class SystemReader {
* @since 5.1.9
*/
public StoredConfig getUserConfig()
- throws IOException, ConfigInvalidException {
+ throws ConfigInvalidException, IOException {
FileBasedConfig c = userConfig.get();
if (c == null) {
userConfig.compareAndSet(null,
openUserConfig(getSystemConfig(), FS.DETECTED));
c = userConfig.get();
- } else {
- // Ensure the parent is up to date
- getSystemConfig();
- }
- if (c.isOutdated()) {
- LOG.debug("loading user config {}", userConfig); //$NON-NLS-1$
- c.load();
}
+ // on the very first call this will check a second time if the system
+ // config is outdated
+ updateAll(c);
return c;
}
@@ -319,21 +315,46 @@ public abstract class SystemReader {
* @since 5.1.9
*/
public StoredConfig getSystemConfig()
- throws IOException, ConfigInvalidException {
+ throws ConfigInvalidException, IOException {
FileBasedConfig c = systemConfig.get();
if (c == null) {
systemConfig.compareAndSet(null,
openSystemConfig(null, FS.DETECTED));
c = systemConfig.get();
}
- if (c.isOutdated()) {
- LOG.debug("loading system config {}", systemConfig); //$NON-NLS-1$
- c.load();
- }
+ updateAll(c);
return c;
}
/**
+ * Update config and its parents if they seem modified
+ *
+ * @param config
+ * configuration to reload if outdated
+ * @throws ConfigInvalidException
+ * if configuration is invalid
+ * @throws IOException
+ * if something went wrong when reading files
+ */
+ private void updateAll(Config config)
+ throws ConfigInvalidException, IOException {
+ if (config == null) {
+ return;
+ }
+ updateAll(config.getBaseConfig());
+ if (config instanceof FileBasedConfig) {
+ FileBasedConfig cfg = (FileBasedConfig) config;
+ if (!cfg.getFile().exists()) {
+ return;
+ }
+ if (cfg.isOutdated()) {
+ LOG.debug("loading config {}", cfg); //$NON-NLS-1$
+ cfg.load();
+ }
+ }
+ }
+
+ /**
* Get the current system time
*
* @return the current system time