| Summary: | TreeFilter does not work if one folder name is a prefix of another folder | ||
|---|---|---|---|
| Product: | [Technology] JGit | Reporter: | Remy Suen <remy.suen> |
| Component: | JGit | Assignee: | 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: | |||
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. 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. Doh. this one seems unfixed still Posted https://git.eclipse.org/r/11597 for review Merged some time ago |
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()); }