[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[egit-dev] Re: 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"))
I'd tried this earlier and it was returning no results... but it turns
out I hadn't made the TreeWalker recursive. Setting it as recursive
fixes that problem... but I'd prefer to not get results from the
subdirs of my subdir. I think the only option is to give the
TreeWalker trees with the root set to my subdir, and not use
recursion. Any other options? Can I get a subdir tree from the
repository?
Brad
>
> would cause it to only consider the items in the "src/main/java"
> subdirectory of your project.
>
> --
> Shawn.