aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2019-12-06 10:19:58 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2019-12-06 10:20:07 +0900
commit8a633bde8aa7a1596c99088cb5ff159ca5c70820 (patch)
treee3457f3f9ab8357c61f29f4e8e053280511453ab /org.eclipse.jgit/src/org/eclipse
parentc42f314b6d2a43ed1bd5806f872fbec6456e1efd (diff)
parent02dc0ca6888c101d9448b69b04ba9f03a0df2c33 (diff)
downloadjgit-8a633bde8aa7a1596c99088cb5ff159ca5c70820.tar.gz
jgit-8a633bde8aa7a1596c99088cb5ff159ca5c70820.zip
Merge branch 'stable-5.6'
* stable-5.6: Cleanup CommitAndLogCommandTest CLI: Add support for excluding paths from Git log command Change-Id: I2f48e16640ab1b13f0c32779422add3162260c50 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
index 66de8ae131..5ea6015afa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
@@ -64,10 +64,7 @@ import org.eclipse.jgit.revwalk.filter.AndRevFilter;
import org.eclipse.jgit.revwalk.filter.MaxCountRevFilter;
import org.eclipse.jgit.revwalk.filter.RevFilter;
import org.eclipse.jgit.revwalk.filter.SkipRevFilter;
-import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
-import org.eclipse.jgit.treewalk.filter.PathFilter;
-import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
-import org.eclipse.jgit.treewalk.filter.TreeFilter;
+import org.eclipse.jgit.treewalk.filter.*;
/**
* A class used to execute a {@code Log} command. It has setters for all
@@ -105,6 +102,7 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
private RevFilter revFilter;
private final List<PathFilter> pathFilters = new ArrayList<>();
+ private final List<TreeFilter> excludeTreeFilters = new ArrayList<>();
private int maxCount = -1;
@@ -133,9 +131,22 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
@Override
public Iterable<RevCommit> call() throws GitAPIException, NoHeadException {
checkCallable();
- if (!pathFilters.isEmpty())
- walk.setTreeFilter(AndTreeFilter.create(
- PathFilterGroup.create(pathFilters), TreeFilter.ANY_DIFF));
+ List<TreeFilter> filters = new ArrayList<>();
+ if (!pathFilters.isEmpty()) {
+ filters.add(AndTreeFilter.create(PathFilterGroup.create(pathFilters), TreeFilter.ANY_DIFF));
+ }
+ if (!excludeTreeFilters.isEmpty()) {
+ for (TreeFilter f : excludeTreeFilters) {
+ filters.add(AndTreeFilter.create(f, TreeFilter.ANY_DIFF));
+ }
+ }
+ if (!filters.isEmpty()) {
+ if (filters.size() == 1) {
+ filters.add(TreeFilter.ANY_DIFF);
+ }
+ walk.setTreeFilter(AndTreeFilter.create(filters));
+
+ }
if (skip > -1 && maxCount > -1)
walk.setRevFilter(AndRevFilter.create(SkipRevFilter.create(skip),
MaxCountRevFilter.create(maxCount)));
@@ -310,6 +321,24 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
}
/**
+ * Show all commits that are not within any of the specified paths. The path
+ * must either name a file or a directory exactly and use <code>/</code>
+ * (slash) as separator. Note that regular expressions or wildcards are not
+ * yet supported. If a path is both added and excluded from the search, then
+ * the exclusion wins.
+ *
+ * @param path
+ * a repository-relative path (with <code>/</code> as separator)
+ * @return {@code this}
+ * @since 5.6
+ */
+ public LogCommand excludePath(String path) {
+ checkCallable();
+ excludeTreeFilters.add(PathFilter.create(path).negate());
+ return this;
+ }
+
+ /**
* Skip the number of commits before starting to show the commit output.
*
* @param skip