summaryrefslogtreecommitdiff
path: root/src/attr_file.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-18 14:42:40 -0700
committerRussell Belfer <rb@github.com>2014-04-18 14:42:40 -0700
commit916fcbd61754f74b350ca689e27563cdbded2d30 (patch)
treebb15608b4bde5f23660ae96c6b7cc30dc545d593 /src/attr_file.c
parente3a2a04ceff1d3657629fd6a7245d9a9fc53f24b (diff)
downloadlibgit2-916fcbd61754f74b350ca689e27563cdbded2d30.tar.gz
Fix ignore difference from git with trailing /*
Ignore patterns that ended with a trailing '/*' were still needing to match against another actual '/' character in the full path. This is not the same behavior as core Git. Instead, we strip a trailing '/*' off of any patterns that were matching and just take it to imply the FNM_LEADING_DIR behavior.
Diffstat (limited to 'src/attr_file.c')
-rw-r--r--src/attr_file.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 8a8d86a2d..57b4da7dd 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -353,6 +353,8 @@ bool git_attr_fnmatch__match(
if (match->flags & GIT_ATTR_FNMATCH_ICASE)
flags |= FNM_CASEFOLD;
+ if (match->flags & GIT_ATTR_FNMATCH_LEADINGDIR)
+ flags |= FNM_LEADING_DIR;
if (match->flags & GIT_ATTR_FNMATCH_FULLPATH) {
filename = path->path;
@@ -543,6 +545,13 @@ int git_attr_fnmatch__parse(
if (--slash_count <= 0)
spec->flags = spec->flags & ~GIT_ATTR_FNMATCH_FULLPATH;
}
+ if (spec->length >= 2 &&
+ pattern[spec->length - 1] == '*' &&
+ pattern[spec->length - 2] == '/') {
+ spec->length -= 2;
+ spec->flags = spec->flags | GIT_ATTR_FNMATCH_LEADINGDIR;
+ /* leave FULLPATH match on, however */
+ }
if ((spec->flags & GIT_ATTR_FNMATCH_FULLPATH) != 0 &&
context != NULL && git_path_root(pattern) < 0)