summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorGustav Karlsson <gustav.karlsson@tieto.com>2013-03-29 00:07:49 +0100
committerGustav Karlsson <gustav.karlsson@tieto.com>2013-04-06 18:23:33 +0200
commitb3e9626743892fb33350264a86a0033d5a9756be (patch)
tree89d63dc4f799c2399c5ea953b96278d15dfc9337 /org.eclipse.jgit.test
parent5d446f410d7044fba165ad3deee7ac83864f0e96 (diff)
downloadjgit-b3e9626743892fb33350264a86a0033d5a9756be.tar.gz
jgit-b3e9626743892fb33350264a86a0033d5a9756be.zip
Added characters to be escaped in file name patterns
Originally, characters could not be escaped in FileNameMatcher patterns. This breaks file name matching when escaped brackets "\[" and "\]" are used in the pattern. A fix has been implemented to allow for any character to be escaped by prepending it with a '\' Bug: 340715 Change-Id: Ie46fd211931fa09ef3a6a712bd1da3d7fb64c5e3 Signed-off-by: Gustav Karlsson <gustav.karlsson@tieto.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java
index ec0724406b..1db6c80304 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java
@@ -802,6 +802,46 @@ public class FileNameMatcherTest {
}
@Test
+ public void testEscapedBracket1() throws Exception {
+ assertMatch("\\[", "[", true, false);
+ }
+
+ @Test
+ public void testEscapedBracket2() throws Exception {
+ assertMatch("\\[[a]", "[", false, true);
+ }
+
+ @Test
+ public void testEscapedBracket3() throws Exception {
+ assertMatch("\\[[a]", "a", false, false);
+ }
+
+ @Test
+ public void testEscapedBracket4() throws Exception {
+ assertMatch("\\[[a]", "[a", true, false);
+ }
+
+ @Test
+ public void testEscapedBracket5() throws Exception {
+ assertMatch("[a\\]]", "]", true, false);
+ }
+
+ @Test
+ public void testEscapedBracket6() throws Exception {
+ assertMatch("[a\\]]", "a", true, false);
+ }
+
+ @Test
+ public void testEscapedBackslash() throws Exception {
+ assertMatch("a\\\\b", "a\\b", true, false);
+ }
+
+ @Test
+ public void testMultipleEscapedCharacters1() throws Exception {
+ assertMatch("\\]a?c\\*\\[d\\?\\]", "]abc*[d?]", true, false);
+ }
+
+ @Test
public void testFilePathSimpleCase() throws Exception {
assertFileNameMatch("a/b", "a/b", '/', true, false);
}