String (@NotNull Project project, @NotNull String projectBaseDir, @NotNull FilePath filePath, boolean acceptEmptyPath) { if (project.isDisposed()) return null; String path = filePath.getPath(); ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); VirtualFile root = vcsManager.getVcsRootFor(filePath); if (root == null) return null; String rootPath = root.getPath(); VcsRoot[] roots = vcsManager.getAllVcsRoots(); if (roots.length == 1) { if (rootPath.equals(path)) return acceptEmptyPath ? "" : root.getName(); return getRelativePathIfSuccessor(rootPath, path); } if (projectBaseDir.equals(path)) { return root.getName(); } String relativePath = getRelativePathIfSuccessor(projectBaseDir, path); if (relativePath == null) return null; return projectBaseDir.equals(rootPath) ? root.getName() + '/' + relativePath : relativePath; }