Java Code Examples for org.eclipse.jgit.util.FS#resolve()

The following examples show how to use org.eclipse.jgit.util.FS#resolve() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitUtils.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
private static File getSymRef(File workTree, File dotGit, FS fs)
		throws IOException {
	byte[] content = IO.readFully(dotGit);
	if (!isSymRef(content))
		throw new IOException(MessageFormat.format(
				JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));

	int pathStart = 8;
	int lineEnd = RawParseUtils.nextLF(content, pathStart);
	if (content[lineEnd - 1] == '\n')
		lineEnd--;
	if (lineEnd == pathStart)
		throw new IOException(MessageFormat.format(
				JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));

	String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
	File gitdirFile = fs.resolve(workTree, gitdirPath);
	if (gitdirFile.isAbsolute())
		return gitdirFile;
	else
		return new File(workTree, gitdirPath).getCanonicalFile();
}
 
Example 2
Source File: IgnoreUnignoreCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private File getGlobalExcludeFile () {
    Repository repository = getRepository();
    String path = repository.getConfig().get(CoreConfig.KEY).getExcludesFile();
    File excludesfile = null;
    FS fs = repository.getFS();
    if (path != null) {
        if (path.startsWith("~/")) {
            excludesfile = fs.resolve(fs.userHome(), path.substring(2));
        } else {
            excludesfile = fs.resolve(null, path);
        }
    }
    return excludesfile;
}