Patterns should treat \r in file names as normal characters Change-Id: Ica3e0fa4a58acf5326db46bb28571fe5f20f6cd2 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>tags/v5.2.0.201811281532-m3
@@ -415,6 +415,14 @@ public class AttributesMatcherTest { | |||
} | |||
} | |||
@Test | |||
public void testFileNameWithLineTerminator() { | |||
assertMatched("a?", "a\r"); | |||
assertMatched("a?", "dir/a\r"); | |||
assertMatched("*a", "\ra"); | |||
assertMatched("dir/*a*", "dir/\ra\r"); | |||
} | |||
/** | |||
* Check for a match. If target ends with "/", match will assume that the | |||
* target is meant to be a directory. |
@@ -512,6 +512,15 @@ public class FastIgnoreRuleTest { | |||
assertMatched("x/**/", "x/y/a/"); | |||
} | |||
@Test | |||
public void testFileNameWithLineTerminator() { | |||
assertMatched("a?", "a\r"); | |||
assertMatched("a?", "dir/a\r"); | |||
assertMatched("a?", "a\r/file"); | |||
assertMatched("*a", "\ra"); | |||
assertMatched("dir/*a*", "dir/\ra\r"); | |||
} | |||
private void assertMatched(String pattern, String path) { | |||
boolean match = match(pattern, path); | |||
String result = path + " is " + (match ? "ignored" : "not ignored") |
@@ -443,7 +443,7 @@ public class Strings { | |||
if (in_brackets > 0) | |||
throw new InvalidPatternException("Not closed bracket?", pattern); //$NON-NLS-1$ | |||
try { | |||
return Pattern.compile(sb.toString()); | |||
return Pattern.compile(sb.toString(), Pattern.DOTALL); | |||
} catch (PatternSyntaxException e) { | |||
throw new InvalidPatternException( | |||
MessageFormat.format(JGitText.get().invalidIgnoreRule, |