Browse Source

Fix IgnoreRule#isMatch returning wrong result due to missing reset

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>
tags/v3.2.0.201312181205-r
Robin Stocker 10 years ago
parent
commit
f4dae204a6

+ 12
- 0
org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreMatcherTest.java View File

@@ -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.

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreRule.java View File

@@ -198,6 +198,7 @@ public class IgnoreRule {
}

} else {
matcher.reset();
matcher.append(target);
if (matcher.isMatch())
return true;

Loading…
Cancel
Save