diff options
author | Christian Georgi | 2013-07-29 03:03:35 -0400 |
---|---|---|
committer | Christian Georgi | 2013-07-29 03:43:18 -0400 |
commit | cb94e50dcd5f8f473938a82ba47f43f2a3e487f2 (patch) | |
tree | 78c53a026509a85d4f6efff6c1032f118b9dafab | |
parent | f3dd6ee9480b905252ac675746e3cda726b6695b (diff) | |
download | egit-cb94e50dcd5f8f473938a82ba47f43f2a3e487f2.zip egit-cb94e50dcd5f8f473938a82ba47f43f2a3e487f2.tar.gz egit-cb94e50dcd5f8f473938a82ba47f43f2a3e487f2.tar.xz |
Consider IResource.getLocation() being null
For non-local projects, i.e. ones backed by other EFS implementations,
IResource.getLocation() is designed to return null (cf.
getLoactionURI()). Honor this fact by checking return values of
getLocation().
Bug: 413887
Change-Id: I7591ce439dc8e3719965a4516c9eb4692cfd5acb
Signed-off-by: Christian Georgi <christian.georgi@sap.com>
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java | 22 | ||||
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java | 3 |
2 files changed, 16 insertions, 9 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 2e26555..eb4947b 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 @@ -320,8 +320,11 @@ public class ProjectUtil { // Sorting makes us look into nested projects first Arrays.sort(allProjects, new Comparator<IProject>() { public int compare(IProject o1, IProject o2) { - return -o1.getLocation().toFile() - .compareTo(o2.getLocation().toFile()); + IPath l1 = o1.getLocation(); + IPath l2 = o2.getLocation(); + if (l1 != null && l2 != null) + return -l1.toFile().compareTo(l2.toFile()); + return 0; } }); @@ -330,13 +333,16 @@ public class ProjectUtil { private static boolean checkContainerMatch(IContainer container, String absFile) { - String absPrj = container.getLocation().toFile().getAbsolutePath(); - if (absPrj.equals(absFile)) - return true; - if (absPrj.length() < absFile.length()) { - char sepChar = absFile.charAt(absPrj.length()); - if (sepChar == File.separatorChar && absFile.startsWith(absPrj)) + IPath location = container.getLocation(); + if (location != null) { + String absPrj = location.toFile().getAbsolutePath(); + if (absPrj.equals(absFile)) return true; + if (absPrj.length() < absFile.length()) { + char sepChar = absFile.charAt(absPrj.length()); + if (sepChar == File.separatorChar && absFile.startsWith(absPrj)) + return true; + } } return false; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java index b1cd082..0eb91a1 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java @@ -301,7 +301,8 @@ public class RemoveCommand extends final IPath wdPath = new Path(workDir.getAbsolutePath()); for (IProject prj : ResourcesPlugin.getWorkspace() .getRoot().getProjects()) { - if (wdPath.isPrefixOf(prj.getLocation())) { + IPath location = prj.getLocation(); + if (location != null && wdPath.isPrefixOf(location)) { projectsToDelete.add(prj); } } |