diff options
author | Jonathan Nieder <jrn@google.com> | 2015-12-16 12:09:48 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2015-12-16 12:09:49 -0500 |
commit | cfa0b2fb3c695bf6698148e5d5626acb17106aed (patch) | |
tree | ff57a654b79aa217a4e119609f3a27389921e567 /org.eclipse.jgit | |
parent | a3e9876d8fe6c818a2405bf5b78234645d489820 (diff) | |
parent | 75a0dcac1883414f5f99eec37ffa9cb305940718 (diff) | |
download | jgit-cfa0b2fb3c695bf6698148e5d5626acb17106aed.tar.gz jgit-cfa0b2fb3c695bf6698148e5d5626acb17106aed.zip |
Merge changes Ib4d53bdd,I55bd512c
* changes:
Do not let PathFilter.create("a/b") match 'a' unless 'a' is a subtree
Add tests for PathFilterGroup.Single
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java | 7 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathFilterGroup.java | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java index 06dc0bf6d0..438549520e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java @@ -861,10 +861,13 @@ public class TreeWalk implements AutoCloseable, AttributesProvider { * Test if the supplied path matches the current entry's path. * <p> * This method tests that the supplied path is exactly equal to the current - * entry, or is one of its parent directories. It is faster to use this + * entry or is one of its parent directories. It is faster to use this * method then to use {@link #getPathString()} to first create a String * object, then test <code>startsWith</code> or some other type of string * match function. + * <p> + * If the current entry is a subtree, then all paths within the subtree + * are considered to match it. * * @param p * path buffer to test. Callers should ensure the path does not @@ -900,7 +903,7 @@ public class TreeWalk implements AutoCloseable, AttributesProvider { // If p[ci] == '/' then pattern matches this subtree, // otherwise we cannot be certain so we return -1. // - return p[ci] == '/' ? 0 : -1; + return p[ci] == '/' && FileMode.TREE.equals(t.mode) ? 0 : -1; } // Both strings are identical. 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 bdfde0bfcd..7601956c43 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 @@ -245,9 +245,9 @@ public class PathFilterGroup { int hash = hasher.nextHash(); if (fullpaths.contains(rp, hasher.length(), hash)) return true; - if (!hasher.hasNext()) - if (prefixes.contains(rp, hasher.length(), hash)) - return true; + if (!hasher.hasNext() && walker.isSubtree() + && prefixes.contains(rp, hasher.length(), hash)) + return true; } final int cmp = walker.isPathPrefix(max, max.length); |