diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-01-27 16:06:15 +0100 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-01-28 16:13:04 +0100 |
commit | e12c6b58ee0284cbdf34bf325deb561a52d10340 (patch) | |
tree | b5d84d4f0757fbbf5ec93fc6c3425d1f72e5d972 /org.eclipse.jgit | |
parent | 1c43af8b9794abcad7a4ac77c352626063aa1f05 (diff) | |
download | jgit-e12c6b58ee0284cbdf34bf325deb561a52d10340.tar.gz jgit-e12c6b58ee0284cbdf34bf325deb561a52d10340.zip |
Minor improvements in git config file inclusions
* Section and key names in git config files are case-insensitive.
* If an include directive is invalid, include the line in the
exception message.
* If inclusion of the included file fails, put the file name into
the exception message so that the user knows in which file the
problem is.
Change-Id: If920943af7ff93f5321b3d315dfec5222091256c
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit')
3 files changed, 12 insertions, 5 deletions
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 74be246659..c43411779d 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -368,6 +368,7 @@ invalidIgnoreRule=Exception caught while parsing ignore rule ''{0}''. invalidIntegerValue=Invalid integer value: {0}.{1}={2} invalidKey=Invalid key: {0} invalidLineInConfigFile=Invalid line in config file +invalidLineInConfigFileWithParam=Invalid line in config file: {0} invalidModeFor=Invalid mode {0} for {1} {2} in {3}. invalidModeForPath=Invalid mode {0} for path {1} invalidObject=Invalid {0} {1}: {2} 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 7f91b30a91..9739672f84 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -429,6 +429,7 @@ public class JGitText extends TranslationBundle { /***/ public String invalidIntegerValue; /***/ public String invalidKey; /***/ public String invalidLineInConfigFile; + /***/ public String invalidLineInConfigFileWithParam; /***/ public String invalidModeFor; /***/ public String invalidModeForPath; /***/ public String invalidObject; 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 a6313f0cc5..4d558c9fc2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java @@ -1125,7 +1125,7 @@ public class Config { } else e.value = readValue(in); - if (e.section.equals("include")) { //$NON-NLS-1$ + if (e.section.equalsIgnoreCase("include")) { //$NON-NLS-1$ addIncludedConfig(newEntries, e, depth); } } else @@ -1154,10 +1154,10 @@ public class Config { private void addIncludedConfig(final List<ConfigLine> newEntries, ConfigLine line, int depth) throws ConfigInvalidException { - if (!line.name.equals("path") || //$NON-NLS-1$ + if (!line.name.equalsIgnoreCase("path") || //$NON-NLS-1$ line.value == null || line.value.equals(MAGIC_EMPTY_VALUE)) { - throw new ConfigInvalidException( - JGitText.get().invalidLineInConfigFile); + throw new ConfigInvalidException(MessageFormat.format( + JGitText.get().invalidLineInConfigFileWithParam, line)); } byte[] bytes = readIncludedConfig(line.value); if (bytes == null) { @@ -1171,7 +1171,12 @@ public class Config { } else { decoded = RawParseUtils.decode(bytes); } - newEntries.addAll(fromTextRecurse(decoded, depth + 1)); + try { + newEntries.addAll(fromTextRecurse(decoded, depth + 1)); + } catch (ConfigInvalidException e) { + throw new ConfigInvalidException(MessageFormat + .format(JGitText.get().cannotReadFile, line.value), e); + } } private ConfigSnapshot newState() { |