diff options
Diffstat (limited to 'src/attr_file.c')
-rw-r--r-- | src/attr_file.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/attr_file.c b/src/attr_file.c index 07ffacbaf..562075291 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -543,7 +543,7 @@ int git_attr_fnmatch__parse( for (scan = pattern; *scan != '\0'; ++scan) { /* scan until (non-escaped) white space */ if (git__isspace(*scan) && *(scan - 1) != '\\') { - if (!allow_space || (*scan != ' ' && *scan != '\t')) + if (!allow_space || (*scan != ' ' && *scan != '\t' && *scan != '\r')) break; } @@ -564,6 +564,15 @@ int git_attr_fnmatch__parse( if ((spec->length = scan - pattern) == 0) return GIT_ENOTFOUND; + /* + * Remove one trailing \r in case this is a CRLF delimited + * file, in the case of Icon\r\r\n, we still leave the first + * \r there to match against. + */ + if (pattern[spec->length - 1] == '\r') + if (--spec->length == 0) + return GIT_ENOTFOUND; + if (pattern[spec->length - 1] == '/') { spec->length--; spec->flags = spec->flags | GIT_ATTR_FNMATCH_DIRECTORY; |