summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java27
-rw-r--r--org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java11
4 files changed, 33 insertions, 7 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 6d07d34d3a..c14c6d7f22 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
@@ -782,10 +782,31 @@ public class ConfigTest {
@Test
public void testIncludeValuePathNotFound() throws ConfigInvalidException {
+ // we do not expect an exception, included path not found are ignored
String notFound = "/not/found";
- expectedEx.expect(ConfigInvalidException.class);
- expectedEx.expectMessage(notFound);
- parse("[include]\npath=" + notFound + "\n");
+ Config parsed = parse("[include]\npath=" + notFound + "\n");
+ assertEquals(1, parsed.getSections().size());
+ assertEquals(notFound, parsed.getString("include", null, "path"));
+ }
+
+ @Test
+ public void testIncludeValuePathWithTilde() throws ConfigInvalidException {
+ // we do not expect an exception, included path not supported are
+ // ignored
+ String notSupported = "~/someFile";
+ Config parsed = parse("[include]\npath=" + notSupported + "\n");
+ assertEquals(1, parsed.getSections().size());
+ assertEquals(notSupported, parsed.getString("include", null, "path"));
+ }
+
+ @Test
+ public void testIncludeValuePathRelative() throws ConfigInvalidException {
+ // we do not expect an exception, included path not supported are
+ // ignored
+ String notSupported = "someRelativeFile";
+ Config parsed = parse("[include]\npath=" + notSupported + "\n");
+ assertEquals(1, parsed.getSections().size());
+ assertEquals(notSupported, parsed.getString("include", null, "path"));
}
@Test
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index b71e48b526..ead8359865 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -339,7 +339,6 @@ invalidId0=Invalid id
invalidIdLength=Invalid id length {0}; should be {1}
invalidIgnoreParamSubmodule=Found invalid ignore param for submodule {0}.
invalidIgnoreRule=Exception caught while parsing ignore rule ''{0}''.
-invalidIncludedPathInConfigFile=Invalid included path in config file: {0}
invalidIntegerValue=Invalid integer value: {0}.{1}={2}
invalidKey=Invalid key: {0}
invalidLineInConfigFile=Invalid line in config file
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index 7c101780a7..a113cd28fc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -398,7 +398,6 @@ public class JGitText extends TranslationBundle {
/***/ public String invalidIdLength;
/***/ public String invalidIgnoreParamSubmodule;
/***/ public String invalidIgnoreRule;
- /***/ public String invalidIncludedPathInConfigFile;
/***/ public String invalidIntegerValue;
/***/ public String invalidKey;
/***/ public String invalidLineInConfigFile;
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 b8eba3acc2..6592823da7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -52,6 +52,7 @@
package org.eclipse.jgit.lib;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -1127,9 +1128,15 @@ public class Config {
decoded = RawParseUtils.decode(bytes);
}
newEntries.addAll(fromTextRecurse(decoded, depth + 1));
+ } catch (FileNotFoundException fnfe) {
+ if (path.exists()) {
+ throw new ConfigInvalidException(MessageFormat
+ .format(JGitText.get().cannotReadFile, path), fnfe);
+ }
} catch (IOException ioe) {
- throw new ConfigInvalidException(MessageFormat.format(
- JGitText.get().invalidIncludedPathInConfigFile, path));
+ throw new ConfigInvalidException(
+ MessageFormat.format(JGitText.get().cannotReadFile, path),
+ ioe);
}
}