summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorAndrey Loskutov <loskutov@gmx.de>2015-09-22 16:42:14 +0200
committerAndrey Loskutov <loskutov@gmx.de>2015-09-24 16:04:57 +0200
commit97ef1fe89369422ca430b47e0b53277b94bfbc29 (patch)
tree2ffee77d3fe10cdcc9239b10ad7c9a1c9ecd7adb /org.eclipse.jgit.test
parent79974e20cc87b10b358deeaafda899ccae4c6cc5 (diff)
downloadjgit-97ef1fe89369422ca430b47e0b53277b94bfbc29.tar.gz
jgit-97ef1fe89369422ca430b47e0b53277b94bfbc29.zip
Properly support special regex characters in ignore rules
Ignore rules should escape $^(){}+| chars if using regular expressions, because they should be treated literally if they aren't part of a character group. Bug: 478055 Change-Id: Ic7276442d7f8f02594b85eae1ef697362e62d3bd Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java
index 05443d60c0..ec4a1f1c67 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreRuleSpecialCasesTest.java
@@ -869,6 +869,84 @@ public class IgnoreRuleSpecialCasesTest {
}
@Test
+ public void testDollar() throws Exception {
+ assertMatch("$", "$", true);
+ assertMatch("$x", "$x", true);
+ assertMatch("$x", "x$", false);
+ assertMatch("$x", "$", false);
+
+ assertMatch("$x.*", "$x.a", true);
+ assertMatch("*$", "x$", true);
+ assertMatch("*.$", "x.$", true);
+
+ assertMatch("$*x", "$ax", true);
+ assertMatch("x*$", "xa$", true);
+ assertMatch("x*$", "xa", false);
+ assertMatch("[a$b]", "$", true);
+ }
+
+ @Test
+ public void testCaret() throws Exception {
+ assertMatch("^", "^", true);
+ assertMatch("^x", "^x", true);
+ assertMatch("^x", "x^", false);
+ assertMatch("^x", "^", false);
+
+ assertMatch("^x.*", "^x.a", true);
+ assertMatch("*^", "x^", true);
+ assertMatch("*.^", "x.^", true);
+
+ assertMatch("x*^", "xa^", true);
+ assertMatch("^*x", "^ax", true);
+ assertMatch("^*x", "ax", false);
+ assertMatch("[a^b]", "^", true);
+ }
+
+ @Test
+ public void testPlus() throws Exception {
+ assertMatch("+", "+", true);
+ assertMatch("+x", "+x", true);
+ assertMatch("+x", "x+", false);
+ assertMatch("+x", "+", false);
+ assertMatch("x+", "xx", false);
+
+ assertMatch("+x.*", "+x.a", true);
+ assertMatch("*+", "x+", true);
+ assertMatch("*.+", "x.+", true);
+
+ assertMatch("x*+", "xa+", true);
+ assertMatch("+*x", "+ax", true);
+ assertMatch("+*x", "ax", false);
+ assertMatch("[a+b]", "+", true);
+ }
+
+ @Test
+ public void testPipe() throws Exception {
+ assertMatch("|", "|", true);
+ assertMatch("|x", "|x", true);
+ assertMatch("|x", "x|", false);
+ assertMatch("|x", "|", false);
+ assertMatch("x|x", "xx", false);
+
+ assertMatch("x|x.*", "x|x.a", true);
+ assertMatch("*|", "x|", true);
+ assertMatch("*.|", "x.|", true);
+
+ assertMatch("x*|a", "xb|a", true);
+ assertMatch("b|*x", "b|ax", true);
+ assertMatch("b|*x", "ax", false);
+ assertMatch("[a|b]", "|", true);
+ }
+
+ @Test
+ public void testBrackets() throws Exception {
+ assertMatch("{}*()", "{}x()", true);
+ assertMatch("[a{}()b][a{}()b]?[a{}()b][a{}()b]", "{}x()", true);
+ assertMatch("x*{x}3", "xa{x}3", true);
+ assertMatch("a*{x}3", "axxx", false);
+ }
+
+ @Test
public void testFilePathSimpleCase() throws Exception {
assertFileNameMatch("a/b", "a/b", true);
}