[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jgit-dev] TreeWalk for folder return RevBlob instead of RevTree
|
Dariusz Luksza <dariusz.luksza@xxxxxxxxx> wrote:
> For some reasons when I pass path to folder in PathFilter I retrieve a
> RevBlob instance instead of RevTree maybe I'm doing something wrong
> here:
>
> TreeWalk tw = new TreeWalk(repo);
> tw.reset();
> tw.setRecursive(true);
> tw.setFilter(PathFilter.create("src/test"))
> int nth = tw.addTree(tree);
>
> if (tw.next())
> return tw.getObjectId(nth);
Its recursive. A recursive TreeWalk automatically skips over
trees and returns only files. Since you passed a directory, its
now going to iterate everything in that directory.
Disable recursive to see trees. Unfortunately you then have to
dive down into src to find test:
tw.setRecursive(false);
tw.setFilter(PathFilter.create("src/test"))
while (tw.next() && !"src/test".equals(tw.getPathString()))
if (tw.isSubtree())
tw.enterSubtree();
I think... matching for a single tree entry nested within a path
is a new corner case we haven't explored before with TreeWalk.
I'm not surprised its giving you trouble. :-(
--
Shawn.