Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [egit-dev] Finding the ObjectID of a subfolder in a repository

Brad Larson <bklarson@xxxxxxxxx> wrote:
> Sorry if this is a dumb question - I've searched around a fair amount.
> 
> I'd like to run a status of a subfolder using jgit.  I can get the
> status of the whole project using code similar to
> http://github.com/sonatype/JGit/blob/1f9dac50f0743b710f95f6370fa801bbac28c4cf/org.spearce.jgit/src/org/spearce/jgit/simple/SimpleRepository.java#L722
> 
> But what is the best way to filter out a subfolder?

Probably just use a TreeFilter:
 
> mTreeWalk = new TreeWalk(mRepo);
> mRevWalk = new RevWalk(mRepo);
> mTreeWalk.addTree(new FileTreeIterator(aRootFolder));
> mTreeWalk.addTree(mRevWalk.parseTree(mRepo.resolve(Constants.HEAD)));

mTreeWalk.setFilter(PathFilter.create("src/main/java"))

would cause it to only consider the items in the "src/main/java"
subdirectory of your project.

-- 
Shawn.


Back to the top