[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Using Filters with JGit to Implement Include and Exclude Paths

Hey JGit community.  I am fairly new to JGit so forgive me if this question have been answered before but here is my situation.

 

I am trying to implement a way to get a list of revisions on a git repository based on include and exclude path filters that I give it.

 

So this is what I originally had in mind:

TreeFilter includeFilter = PathFilterGroup.createfromStrings(includePaths);

TreeFilter excludeFilter = NotTreeFilter.create(PathFilterGroup.createFromStrings(excludePaths));

 

TreeFilter pathFilter = AndTreeFilter.create(includeFilter, excludeFilter);

revWalk.setTreeFilter(pathFilter);

 

Now obviously this is just a simplified version that doesnât take into account empty include and exclude path lists and the inclusion of the â/â in either list.  But this is just an idea of what I was thinking. 

 

After writing tests for this setup it wasnât working and I came to the conclusion that I didnât want the quick abort feature of PathFilterGroup so I switched to using something like this:

 

TreeFilter includeFilter = OrTreeFilter.create(includePathFiltersArray);

TreeFilter excludeFilter = NotTreeFilter.create(OrTreeFilter.create (excludePathFiltersArray));

 

TreeFilter pathFilter = AndTreeFilter.create(includeFilter, excludeFilter);

revWalk.setTreeFilter(pathFilter);

 

However now I am noticing that the Exclude Filter is not behaving as I would expect it to.  I guess that makes sense as it seems that allot of these filters are not designed to handle the type of filter wrapping that I am trying to do.  It seems like the Exclude Filter doesnât keep trying to filter recursively as I would expect it to.

 

I was looking for documentation on what I was trying to do but I couldnât find anything.  Does anyone have any ideas or resources that could help me out?  Thanks for your time.

 

 

Evan Knapp
Software Engineer Int - PD,
JDA Software | 20700 Swenson Drive, Waukesha, WI 53186

1.262.317.2159 | office
1.480.308.3000
| worldwide
email | Evan.Knapp@xxxxxxx
visit us
|
jda.com

 

Donât Miss FOCUS 2015 Orlando â over 100 customer-led sessions and 1 Grammy-winning singer! Learn More >

PNG image