Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362430

Summary: TreeFilter does not work if one folder name is a prefix of another folder
Product: [Technology] JGit Reporter: Remy Suen <remy.suen>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: robin.rosenberg, spearce
Version: 1.2   
Target Milestone: 3.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Remy Suen CLA 2011-10-30 08:20:32 EDT
The code below only prints 'org.eclipse.jgit.console' when it should also print 'org.eclipse.jgit'.

Repository repository = new FileRepository(
    new File(/* your jgit folder */));
TreeWalk walk = new TreeWalk(repository);
TreeFilter filter = PathFilterGroup.createFromStrings(
    "org.eclipse.jgit",
    "org.eclipse.jgit.console");
walk.setFilter(filter);
walk.addTree(new FileTreeIterator(repository));
while (walk.next()) {
  System.out.println(walk.getPathString());
}
Comment 1 Remy Suen CLA 2011-10-30 09:03:59 EDT
In WorkingTreeIterator's list of entries, the org.eclipse.jgit entry comes after the org.eclipse.jgit.console entry. When PathFilterGroup.Group throws the StopWalkException for performance reason, we eagerly return and do not get a chance to check the filtering against the org.eclipse.jgit entry.

Downgrading the severity as the workaround is to use PathFilter instead of PathFilterGroup for creating the filters.
Comment 2 Robin Rosenberg CLA 2011-11-04 22:24:33 EDT
The problem is that internally the sort order for org.eclipse.jgit and org.eclipse.jgit.console is different depending on whether they represent tree's or non-trees.
Comment 3 Robin Rosenberg CLA 2013-04-01 19:05:47 EDT
Doh. this one seems unfixed still
Comment 4 Robin Rosenberg CLA 2013-04-02 03:02:11 EDT
Posted https://git.eclipse.org/r/11597 for review
Comment 5 Robin Rosenberg CLA 2013-04-19 04:41:12 EDT
Merged some time ago