]> source.dussan.org Git - jgit.git/commitdiff
Fix false positives in hashing used by PathFilterGroup 95/10495/4
authorRobin Stocker <robin@nibor.org>
Tue, 19 Feb 2013 22:41:15 +0000 (23:41 +0100)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 19 Feb 2013 23:37:57 +0000 (00:37 +0100)
The ByteArraySet failed to check the length of the entry correctly leading
to matches where no match should be.

Bug: 401249
Change-Id: I925bc48d9cafcdf13e1a797bb09fc2555eb270c5
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/ByteArraySet.java

index 5267e81a15b54fbf40858e157d74da3ed623d03c..8038206e9b6646db360d5ee63dba69798d5b73a8 100644 (file)
@@ -134,6 +134,19 @@ public class PathFilterGroupTest {
                assertTrue(filter.include(fakeWalk("d/e/f/g/h")));
        }
 
+       @Test
+       public void testLongPaths() throws MissingObjectException,
+                       IncorrectObjectTypeException, IOException {
+               TreeFilter longPathFilter = PathFilterGroup
+                               .createFromStrings(
+                                               "tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java",
+                                               "tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest2.java");
+               assertFalse(longPathFilter
+                               .include(fakeWalk("tst/org/eclipse/jgit/treewalk/FileTreeIteratorTest.java")));
+               assertFalse(longPathFilter.include(fakeWalk("tst/a-other-in-same")));
+               assertFalse(longPathFilter.include(fakeWalk("a-nothing-in-common")));
+       }
+
        @Test
        public void testStopWalk() throws MissingObjectException,
                        IncorrectObjectTypeException, IOException {
index 0df24af24fb5a0c94037657db4d063a0cc57de1d..5a35359821d9a4bff09c9cf9c58990b95abc45cd 100644 (file)
@@ -88,7 +88,7 @@ class ByteArraySet {
        }
 
        private static boolean equals(byte[] a, byte[] b, int length) {
-               if (a.length < length || b.length < length)
+               if (a.length != length || b.length < length)
                        return false;
                for (int i = 0; i < length; ++i) {
                        if (a[i] != b[i])