summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorXing Huang <xingkhuang@google.com>2024-03-15 15:19:15 -0500
committerXing Huang <xingkhuang@google.com>2024-03-18 10:51:11 -0500
commit9e841dd4ac8435b97333c380eaa34e7bf01be97e (patch)
treea0c18e35dccc151b601885ab02cca0223b20a5b4 /org.eclipse.jgit
parentc1eba8abe04493ceb9b30c4f747fb0255c4f28e1 (diff)
downloadjgit-9e841dd4ac8435b97333c380eaa34e7bf01be97e.tar.gz
jgit-9e841dd4ac8435b97333c380eaa34e7bf01be97e.zip
PathFilterGroup: implement getPathsBestEffort()
getPathsBestEffort() is a method in the TreeFilter class to retrieve file paths specified by the caller. PathFilterGroup do not propagate the paths of their subfilters as it does not implement the getPathsBestEffort() method, resulting in the caller only getting an empty list of paths. Override getPathsBestEffort() in PathFilterGroup to propagate subfilter values. Signed-off-by: Xing Huang <xingkhuang@google.com> Change-Id: I76bf08795360abc0874a7c258636d4f37da35060
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/ByteArraySet.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java11
2 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/ByteArraySet.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/ByteArraySet.java
index c94160144e..bcf79a285d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/ByteArraySet.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/ByteArraySet.java
@@ -15,6 +15,10 @@ package org.eclipse.jgit.treewalk.filter;
import org.eclipse.jgit.util.RawParseUtils;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.stream.Collectors;
+
/**
* Specialized set for byte arrays, interpreted as strings for use in
* {@link PathFilterGroup.Group}. Most methods assume the hash is already know
@@ -291,4 +295,8 @@ class ByteArraySet {
return ret;
}
+ Set<byte[]> toSet() {
+ return Arrays.stream(toArray()).collect(Collectors.toSet());
+ }
+
}
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 59855572f2..4c0604ad56 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
@@ -12,6 +12,8 @@
package org.eclipse.jgit.treewalk.filter;
import java.util.Collection;
+import java.util.Optional;
+import java.util.Set;
import org.eclipse.jgit.errors.StopWalkException;
import org.eclipse.jgit.internal.JGitText;
@@ -232,6 +234,15 @@ public class PathFilterGroup {
}
@Override
+ public Optional<Set<byte[]>> getPathsBestEffort() {
+ Set<byte[]> result = fullpaths.toSet();
+ if (result.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.of(result);
+ }
+
+ @Override
public TreeFilter clone() {
return this;
}