aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-09-29 13:16:29 (EDT)
committerChris Aniszczyk2011-09-30 18:00:53 (EDT)
commit654f7235ec49d15641c0f3e54ee140017d18ac3d (patch)
tree76d132e9bda03e8cf9034fb4b20481aea45f0592
parent458b5a4042e2aa2edc48ea596a4079fe5012bae3 (diff)
downloadjgit-654f7235ec49d15641c0f3e54ee140017d18ac3d.zip
jgit-654f7235ec49d15641c0f3e54ee140017d18ac3d.tar.gz
jgit-654f7235ec49d15641c0f3e54ee140017d18ac3d.tar.bz2
Add varargs version of PathFilterGroup.createFromStringsrefs/changes/09/4309/4
This allows the following usage pattern: PathFilterGroup.createFromStrings("path1", "path2"); Change-Id: I589e758cc55873ce75614602e017ac793435e24d Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java
index 756b000..27b1b10 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java
@@ -92,6 +92,33 @@ public class PathFilterGroup {
}
/**
+ * Create a collection of path filters from Java strings.
+ * <p>
+ * Path strings are relative to the root of the repository. If the user's
+ * input should be assumed relative to a subdirectory of the repository the
+ * caller must prepend the subdirectory's path prior to creating the filter.
+ * <p>
+ * Path strings use '/' to delimit directories on all platforms.
+ * <p>
+ * Paths may appear in any order. Sorting may be done internally when the
+ * group is constructed if doing so will improve path matching performance.
+ *
+ * @param paths
+ * the paths to test against. Must have at least one entry.
+ * @return a new filter for the paths supplied.
+ */
+ public static TreeFilter createFromStrings(final String... paths) {
+ if (paths.length == 0)
+ throw new IllegalArgumentException(
+ JGitText.get().atLeastOnePathIsRequired);
+ final int length = paths.length;
+ final PathFilter[] p = new PathFilter[length];
+ for (int i = 0; i < length; i++)
+ p[i] = PathFilter.create(paths[i]);
+ return create(p);
+ }
+
+ /**
* Create a collection of path filters.
* <p>
* Paths may appear in any order within the collection. Sorting may be done