Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-08-09 01:51:36 +0400
committerRussell Belfer <rb@github.com>2014-08-09 01:51:36 +0400
commitf25bc0b2e6d764a496047e4f033767303b35b27e (patch)
treefe48c18e00224e9193cf2adc2b03c966e8d6da6e /src/attr_file.c
parent35f186b6ca84a5e95de2e735834a87e19e7031d2 (diff)
Fix rejection of parent dir of negated ignores
While scanning through a directory hierarchy, this prevents a positive ignore match on a parent directory from blocking the scan of a directory when a negative match rule exists for files inside the directory.
Diffstat (limited to 'src/attr_file.c')
-rw-r--r--src/attr_file.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 3e95a2134..2f0953736 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -378,6 +378,18 @@ bool git_attr_fnmatch__match(
return (matchval != FNM_NOMATCH);
}
+ /* if path is a directory prefix of a negated pattern, then match */
+ if ((match->flags & GIT_ATTR_FNMATCH_NEGATIVE) && path->is_dir) {
+ size_t pathlen = strlen(path->path);
+ bool prefixed = (pathlen <= match->length) &&
+ ((match->flags & GIT_ATTR_FNMATCH_ICASE) ?
+ !strncasecmp(match->pattern, path->path, pathlen) :
+ !strncmp(match->pattern, path->path, pathlen));
+
+ if (prefixed && git_path_at_end_of_segment(&match->pattern[pathlen]))
+ return true;
+ }
+
return (p_fnmatch(match->pattern, filename, flags) != FNM_NOMATCH);
}