gitignore/gitattributes: fix matching of \r
Patterns should treat \r in file names as normal characters Change-Id: Ica3e0fa4a58acf5326db46bb28571fe5f20f6cd2 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
This commit is contained in:
parent
bcf7eb02c2
commit
aaf71bfbcc
|
@ -415,6 +415,14 @@ public void testBracketsInGroup() {
|
|||
}
|
||||
}
|
||||
|
||||
@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 void testPathMatch() {
|
|||
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 @@ && isLetter(lookAhead(pattern, i)))
|
|||
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,
|
||||
|
|
Loading…
Reference in New Issue