If the repository root is more than one level above the project directory we use the AdaptableFileTreeIterator to recurse the repository tree until we find a directory that can be mapped to a container in the workspace. The iterator is then adapted to a ContainerTreeIterator and decorations are applied like usual. Signed-off-by: Tor Arne Vestbø <torarnv@xxxxxxxxx> --- .../decorators/DecoratableResourceAdapter.java | 39 +++++++++++++------- 1 files changed, 26 insertions(+), 13 deletions(-) diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/DecoratableResourceAdapter.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/DecoratableResourceAdapter.java index e2fe54b..5c68d5b 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/DecoratableResourceAdapter.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/DecoratableResourceAdapter.java @@ -13,15 +13,17 @@ package org.spearce.egit.ui.internal.decorators; +import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.Set; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.team.core.Team; +import org.spearce.egit.core.AdaptableFileTreeIterator; import org.spearce.egit.core.ContainerTreeIterator; import org.spearce.egit.core.ContainerTreeIterator.ResourceEntry; import org.spearce.egit.core.project.RepositoryMapping; @@ -39,6 +41,7 @@ import org.spearce.jgit.revwalk.RevWalk; import org.spearce.jgit.treewalk.EmptyTreeIterator; import org.spearce.jgit.treewalk.TreeWalk; +import org.spearce.jgit.treewalk.WorkingTreeIterator; import org.spearce.jgit.treewalk.filter.AndTreeFilter; import org.spearce.jgit.treewalk.filter.PathFilterGroup; import org.spearce.jgit.treewalk.filter.TreeFilter; @@ -210,13 +213,21 @@ public boolean include(TreeWalk treeWalk) } private boolean shouldRecurse(TreeWalk treeWalk) { - final ContainerTreeIterator workspaceIterator = treeWalk.getTree( - T_WORKSPACE, ContainerTreeIterator.class); - final ResourceEntry resourceEntry = workspaceIterator != null ? workspaceIterator - .getResourceEntry() - : null; - IResource visitingResource = resourceEntry.getResource(); + final WorkingTreeIterator workspaceIterator = treeWalk.getTree( + T_WORKSPACE, WorkingTreeIterator.class); + + if (workspaceIterator instanceof AdaptableFileTreeIterator) + return true; + + ResourceEntry resourceEntry = null; + if (workspaceIterator != null) + resourceEntry = ((ContainerTreeIterator) workspaceIterator) + .getResourceEntry(); + + if (resourceEntry == null) + return true; + IResource visitingResource = resourceEntry.getResource(); if (targetDepth == -1) { if (visitingResource.equals(resource) || visitingResource.getParent().equals(resource)) @@ -319,14 +330,16 @@ private TreeWalk createThreeWayTreeWalk() throws IOException { // Working directory IProject project = resource.getProject(); - IWorkspace workspace = resource.getWorkspace(); - if (repository.getWorkDir().equals(project.getLocation().toFile())) + IWorkspaceRoot workspaceRoot = resource.getWorkspace().getRoot(); + File repoRoot = repository.getWorkDir(); + + if (repoRoot.equals(project.getLocation().toFile())) treeWalk.addTree(new ContainerTreeIterator(project)); + else if (repoRoot.equals(workspaceRoot.getLocation().toFile())) + treeWalk.addTree(new ContainerTreeIterator(workspaceRoot)); else - treeWalk.addTree(new ContainerTreeIterator(workspace.getRoot())); - - // TODO: Add fallback for projects with the repository more than - // one parent up, for example by using a stack of DummyIterators + treeWalk.addTree(new AdaptableFileTreeIterator(repoRoot, + workspaceRoot)); return treeWalk; } -- 1.6.1.2.309.g2ea3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html