aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Strapetz <marc.strapetz@syntevo.com>2018-08-25 11:33:17 +0200
committerMarc Strapetz <marc.strapetz@syntevo.com>2018-09-20 17:05:39 +0200
commit31abb329b42f3bab4d683bd1c709ab55f0d29ef6 (patch)
treee498bbe6cc7ed7402525638a71456db1cc3ba2cb
parent4741b072bd07e49dd77c7d777fda3eb8617eefc4 (diff)
downloadjgit-31abb329b42f3bab4d683bd1c709ab55f0d29ef6.tar.gz
jgit-31abb329b42f3bab4d683bd1c709ab55f0d29ef6.zip
ConfigLine.includedFrom stores source, if it was read from included file
This is a base change which prepares for subsequent bugfixes. Change-Id: Iaadc93df37e45753d700be73669e68c03590adb5 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java4
2 files changed, 10 insertions, 5 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 b666f21d0b..6a8ff5ade4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -1060,11 +1060,11 @@ public class Config {
* made to {@code this}.
*/
public void fromText(String text) throws ConfigInvalidException {
- state.set(newState(fromTextRecurse(text, 1)));
+ state.set(newState(fromTextRecurse(text, 1, null)));
}
- private List<ConfigLine> fromTextRecurse(String text, int depth)
- throws ConfigInvalidException {
+ private List<ConfigLine> fromTextRecurse(String text, int depth,
+ String includedFrom) throws ConfigInvalidException {
if (depth > MAX_DEPTH) {
throw new ConfigInvalidException(
JGitText.get().tooManyIncludeRecursions);
@@ -1073,6 +1073,7 @@ public class Config {
final StringReader in = new StringReader(text);
ConfigLine last = null;
ConfigLine e = new ConfigLine();
+ e.includedFrom = includedFrom;
for (;;) {
int input = in.read();
if (-1 == input) {
@@ -1088,7 +1089,7 @@ public class Config {
if (e.section != null)
last = e;
e = new ConfigLine();
-
+ e.includedFrom = includedFrom;
} else if (e.suffix != null) {
// Everything up until the end-of-line is in the suffix.
e.suffix += c;
@@ -1173,7 +1174,7 @@ public class Config {
decoded = RawParseUtils.decode(bytes);
}
try {
- newEntries.addAll(fromTextRecurse(decoded, depth + 1));
+ newEntries.addAll(fromTextRecurse(decoded, depth + 1, line.value));
} catch (ConfigInvalidException e) {
throw new ConfigInvalidException(MessageFormat
.format(JGitText.get().cannotReadFile, line.value), e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java
index 937ba925c5..e623a8cebc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java
@@ -73,6 +73,9 @@ class ConfigLine {
/** The text content after entry. */
String suffix;
+ /** The source from which this line was included from. */
+ String includedFrom;
+
ConfigLine forValue(String newValue) {
final ConfigLine e = new ConfigLine();
e.prefix = prefix;
@@ -81,6 +84,7 @@ class ConfigLine {
e.name = name;
e.value = newValue;
e.suffix = suffix;
+ e.includedFrom = includedFrom;
return e;
}