diff options
author | Robin Stocker <robin@nibor.org> | 2013-07-08 10:51:52 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2013-08-21 14:44:47 +0200 |
commit | c128100800edf6d2cf9c3106a8dc97b04b96f099 (patch) | |
tree | 99d4d6c0252d3eb48616689b0113500b59d01dc3 /org.eclipse.jgit | |
parent | c222b1880861e80898befff17ee3cf0d5414521e (diff) | |
download | jgit-c128100800edf6d2cf9c3106a8dc97b04b96f099.tar.gz jgit-c128100800edf6d2cf9c3106a8dc97b04b96f099.zip |
Fix bugs in TreeWalk#isPathSuffix used by PathSuffixFilter
* It didn't check the first character in the pattern due to a off-by-one
error. Spotted by James Roper.
* It returned true even when pattern was longer than current path, e.g.
it returned that ".txt" is suffix of "txt".
Bug: 411999
Change-Id: I9fbcd68a11fb57cc49956b70c387a47271a0424f
Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java | 10 |
1 files changed, 7 insertions, 3 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 627df927b4..90850eafda 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java @@ -835,13 +835,17 @@ public class TreeWalk { final AbstractTreeIterator t = currentHead; final byte[] c = t.path; final int cLen = t.pathLen; - int ci; - for (ci = 1; ci < cLen && ci < pLen; ci++) { - if (c[cLen-ci] != p[pLen-ci]) + for (int i = 1; i <= pLen; i++) { + // Pattern longer than current path + if (i > cLen) + return false; + // Current path doesn't match pattern + if (c[cLen - i] != p[pLen - i]) return false; } + // Whole pattern tested -> matches return true; } |