diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2019-06-05 13:04:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-05 13:04:25 -0400 |
| commit | e2d4f09da1a9ae08b8942e8d4e20d831aab4ec7b (patch) | |
| tree | 00ae4ea8f1c9baf39b0c2fd2ea48fdb14b16acf3 /src | |
| parent | ac070afecc33e9f263353455debd07876b0e91bf (diff) | |
| parent | 4bcebe2c92d52739e2ea7a92abb26df32ffc2423 (diff) | |
| download | libgit2-e2d4f09da1a9ae08b8942e8d4e20d831aab4ec7b.tar.gz | |
Merge pull request #5076 from libgit2/ethomson/ignore_spaces
Ignore files: don't ignore whitespace
Diffstat (limited to 'src')
| -rw-r--r-- | src/attr_file.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/attr_file.c b/src/attr_file.c index ddd44703a..aef3e64af 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -583,8 +583,11 @@ int git_attr_fnmatch__parse( pattern = *base; - while (git__isspace(*pattern)) pattern++; - if (!*pattern || *pattern == '#') { + while (!allow_space && git__isspace(*pattern)) + pattern++; + + if (!*pattern || *pattern == '#' || *pattern == '\n' || + (*pattern == '\r' && *(pattern + 1) == '\n')) { *base = git__next_line(pattern); return GIT_ENOTFOUND; } @@ -606,8 +609,12 @@ int git_attr_fnmatch__parse( slash_count = 0; for (scan = pattern; *scan != '\0'; ++scan) { - /* scan until (non-escaped) white space */ - if (git__isspace(*scan) && *(scan - 1) != '\\') { + /* + * Scan until a non-escaped whitespace: find a whitespace, then look + * one char backward to ensure that it's not prefixed by a `\`. + * Only look backward if we're not at the first position (`pattern`). + */ + if (git__isspace(*scan) && scan > pattern && *(scan - 1) != '\\') { if (!allow_space || (*scan != ' ' && *scan != '\t' && *scan != '\r')) break; } |
