diff options
author | Laurent Goubet | 2014-06-12 07:53:04 +0000 |
---|---|---|
committer | Laurent Goubet | 2014-07-01 09:38:31 +0000 |
commit | d7d0dd68358bf200382d49b52a3c61fa29ef61b1 (patch) | |
tree | 08e0809e0524ac389ec21b4a9fa396f8cf25fc04 | |
parent | e735ec0cbcd22d12e979027255e4bb26c3c424f1 (diff) | |
download | org.eclipse.emf.compare-d7d0dd68358bf200382d49b52a3c61fa29ef61b1.tar.gz org.eclipse.emf.compare-d7d0dd68358bf200382d49b52a3c61fa29ef61b1.tar.xz org.eclipse.emf.compare-d7d0dd68358bf200382d49b52a3c61fa29ef61b1.zip |
avoid failures comparing files at repository root
Change-Id: I15480b7547b4ef6708045d2d9c29b703d0b96afb
-rw-r--r-- | plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java index 080fcfe01..8dfd079c0 100644 --- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java +++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/utils/ResourceUtil.java @@ -26,6 +26,7 @@ import org.eclipse.core.resources.IStorage; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; @@ -240,14 +241,15 @@ public final class ResourceUtil { } final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - if (root != null) { - if (root.getFile(new Path(path)).exists()) { + final IPath iPath = new Path(path); + if (root != null && iPath.segmentCount() >= 2) { + if (root.getFile(iPath).exists()) { uri = URI.createPlatformResourceURI(path, true); } else { // is it a file coming from a Git repository? - final int indexOfSeparator = path.indexOf('/'); - if (indexOfSeparator > 0 && root.getFile(new Path(path.substring(indexOfSeparator))).exists()) { - uri = URI.createPlatformResourceURI(path.substring(indexOfSeparator), true); + final IPath trimmed = iPath.removeFirstSegments(1); + if (trimmed.segmentCount() >= 2 && root.getFile(trimmed).exists()) { + uri = URI.createPlatformResourceURI(trimmed.toString(), true); } } } |