Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java18
1 files changed, 8 insertions, 10 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
index 2339c03079..bd2668254c 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
@@ -70,19 +70,17 @@ public class ProjectUtil {
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
.getProjects();
List<IProject> result = new ArrayList<IProject>();
- final File parentFile = repository.getWorkTree();
+ final Path repositoryPath = new Path(
+ repository.getWorkTree().getAbsolutePath());
for (IProject p : projects) {
IPath projectLocation = p.getLocation();
- if (!p.isOpen() || projectLocation == null)
+ if (!p.isOpen() || projectLocation == null
+ || !repositoryPath.isPrefixOf(projectLocation))
continue;
- String projectFilePath = projectLocation.append(
- IProjectDescription.DESCRIPTION_FILE_NAME).toOSString();
- File projectFile = new File(projectFilePath);
- if (projectFile.exists()) {
- final File file = p.getLocation().toFile();
- if (file.getAbsolutePath().startsWith(
- parentFile.getAbsolutePath()))
- result.add(p);
+ IPath projectFilePath = projectLocation
+ .append(IProjectDescription.DESCRIPTION_FILE_NAME);
+ if (projectFilePath.toFile().exists()) {
+ result.add(p);
}
}
return result.toArray(new IProject[result.size()]);

Back to the top