diff options
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java index 6cfd352ec1..ba62418e1d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java @@ -55,6 +55,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.text.MessageFormat; +import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.LockFailedException; import org.eclipse.jgit.internal.JGitText; @@ -74,6 +75,8 @@ import org.eclipse.jgit.util.RawParseUtils; public class FileBasedConfig extends StoredConfig { private final File configFile; + private final FS fs; + private boolean utf8Bom; private volatile FileSnapshot snapshot; @@ -107,6 +110,7 @@ public class FileBasedConfig extends StoredConfig { public FileBasedConfig(Config base, File cfgLocation, FS fs) { super(base); configFile = cfgLocation; + this.fs = fs; this.snapshot = FileSnapshot.DIRTY; this.hash = ObjectId.zeroId(); } @@ -240,4 +244,30 @@ public class FileBasedConfig extends StoredConfig { public boolean isOutdated() { return snapshot.isModified(getFile()); } + + /** + * @since 4.10 + */ + @Override + @Nullable + protected byte[] readIncludedConfig(String relPath) + throws ConfigInvalidException { + final File file; + if (relPath.startsWith("~/")) { //$NON-NLS-1$ + file = fs.resolve(fs.userHome(), relPath.substring(2)); + } else { + file = fs.resolve(configFile.getParentFile(), relPath); + } + + if (!file.exists()) { + return null; + } + + try { + return IO.readFully(file); + } catch (IOException ioe) { + throw new ConfigInvalidException(MessageFormat + .format(JGitText.get().cannotReadFile, relPath), ioe); + } + } } |