aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Georgi2013-07-29 03:03:35 (EDT)
committerChristian Georgi2013-07-29 03:43:18 (EDT)
commitcb94e50dcd5f8f473938a82ba47f43f2a3e487f2 (patch)
tree78c53a026509a85d4f6efff6c1032f118b9dafab
parentf3dd6ee9480b905252ac675746e3cda726b6695b (diff)
downloadegit-cb94e50dcd5f8f473938a82ba47f43f2a3e487f2.zip
egit-cb94e50dcd5f8f473938a82ba47f43f2a3e487f2.tar.gz
egit-cb94e50dcd5f8f473938a82ba47f43f2a3e487f2.tar.bz2
Consider IResource.getLocation() being nullrefs/changes/18/14918/1
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.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java3
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);
}
}