diff options
| author | Dariusz Luksza | 2010-06-20 21:15:46 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2010-06-20 21:15:46 +0000 |
| commit | 41ada1c42f7a02d06e8e2030f4c81455e2319aca (patch) | |
| tree | 137aeec0f9b625133eca907b7ba02a5027554960 | |
| parent | ba6eb8c99f603e5d570785d9d9a4a165bf8a34ba (diff) | |
| download | egit-41ada1c42f7a02d06e8e2030f4c81455e2319aca.tar.gz egit-41ada1c42f7a02d06e8e2030f4c81455e2319aca.tar.xz egit-41ada1c42f7a02d06e8e2030f4c81455e2319aca.zip | |
Fix NPE when deleting project used in Synchronize View
NPE is hit when user deletes project that currently is used in
Sychronize View.
Bug: 317368
Change-Id: I4a06c24659f555882c32d9f24aaf738d90c1f2d0
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| -rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java index bcfa476434..3eec66b762 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTree.java @@ -216,6 +216,8 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree { private IResourceVariant findFolderVariant(IResource resource, Repository repository) { File workDir = repository.getWorkDir(); + if (resource.getLocation() == null) + return null; File resourceLocation = resource.getLocation().toFile(); String resLocationAbsolutePath = resourceLocation.getAbsolutePath(); @@ -223,10 +225,8 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree { String entryName = entry.getKey(); File file = new File(workDir, entryName); - if (file.getAbsolutePath().startsWith(resLocationAbsolutePath)) { + if (file.getAbsolutePath().startsWith(resLocationAbsolutePath)) return new GitFolderResourceVariant(resource); - } - } return null; @@ -234,8 +234,11 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree { private IResourceVariant findFileVariant(IResource resource, Repository repository) throws TeamException { - String gitPath = RepositoryMapping.getMapping(resource) - .getRepoRelativePath(resource); + RepositoryMapping repoMapping = RepositoryMapping.getMapping(resource); + if (repoMapping == null) + return null; + + String gitPath = repoMapping.getRepoRelativePath(resource); ObjectId objectId = updated.get(gitPath); if (objectId != null) { File root = repository.getWorkDir(); @@ -266,8 +269,8 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree { public void flushVariants(IResource resource, int depth) throws TeamException { - // nothing do to here - // TODO implement ? + if (!gsdData.getData(resource.getProject()).shouldIncludeLocal()) + store.flushBytes(resource, depth); } @Override @@ -360,7 +363,10 @@ abstract class GitResourceVariantTree extends AbstractResourceVariantTree { protected IResourceVariant fetchVariant(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { try { - return fetchVariant(resource, monitor); + if (resource != null) + return fetchVariant(resource, monitor); + else + return null; } finally { monitor.done(); } |
