Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 d911efc1d1..aa98696b24 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 e0c780feec..980f2094bd 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;

Back to the top