Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2016-03-02 09:25:27 -0500
committerAndrey Loskutov2016-03-02 14:05:31 -0500
commit1564e74398f0281674585a06e6ab330ca8f4d1de (patch)
treef2f20aa93a06c208028036914d547bccf73ec923
parentec367f9865d38aa4fe56d27de473db85d1172d71 (diff)
downloadegit-1564e74398f0281674585a06e6ab330ca8f4d1de.tar.gz
egit-1564e74398f0281674585a06e6ab330ca8f4d1de.tar.xz
egit-1564e74398f0281674585a06e6ab330ca8f4d1de.zip
Fix wrong path comparison via file.getAbsolutePath().startsWith(..)
Path comparisons need to use proper path semantics. This is a follow-up to 5dc7ac99cb0b52ad87e2c563f5dfecf9a800e82c and fixes an IAE on Pull: "Attempted to beginRule [..] does not match outer scope rule [..]". Bug: 488862 Change-Id: I0dc3b287e86b3b01f4a560a97b5f4c2a783107c9 Signed-off-by: Markus Keller <markus_keller@ch.ibm.com>
-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 2339c0307..bd2668254 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