aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2013-12-03 16:25:40 (EST)
committerRobin Stocker2013-12-03 16:30:14 (EST)
commitf4dae204a6a2a1a85e8a90a5e89187f3415099e3 (patch)
tree9f239f3ceb3135fe4aca3f100d3c43b1cefc6aba
parent7dc8a4f089c1ca4762cf6fbf2e77898607a5820a (diff)
downloadjgit-f4dae204a6a2a1a85e8a90a5e89187f3415099e3.zip
jgit-f4dae204a6a2a1a85e8a90a5e89187f3415099e3.tar.gz
jgit-f4dae204a6a2a1a85e8a90a5e89187f3415099e3.tar.bz2
Fix IgnoreRule#isMatch returning wrong result due to missing resetrefs/changes/71/19271/1
The matcher has to be reset before using it, as was already done in the other cases. Bug: 423039 Change-Id: I87abaa7ad7f0aac8651db6e88d41427cacb4d776 Also-by: Ondrej Vrabec <ovrabec@netbeans.org> Signed-off-by: Robin Stocker <robin@nibor.org>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherTest.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java1
2 files changed, 13 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherTest.java
index d911efc..aa98696 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherTest.java
@@ -340,6 +340,18 @@ public class IgnoreMatcherTest {
assertEquals(r.getPattern(), "/patter?");
}
+ @Test
+ public void testResetState() {
+ String pattern = "/build/*";
+ String target = "/build";
+ // Don't use the assert methods of this class, as we want to test
+ // whether the state in IgnoreRule is reset properly
+ IgnoreRule r = new IgnoreRule(pattern);
+ // Result should be the same for the same inputs
+ assertFalse(r.isMatch(target, true));
+ assertFalse(r.isMatch(target, true));
+ }
+
/**
* Check for a match. If target ends with "/", match will assume that the
* target is meant to be a directory.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java
index e0c780f..980f209 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java
@@ -198,6 +198,7 @@ public class IgnoreRule {
}
} else {
+ matcher.reset();
matcher.append(target);
if (matcher.isMatch())
return true;