summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike McQuaid <mike@mikemcquaid.com>2015-04-17 18:27:28 -0700
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-18 21:06:04 +0200
commitb67bc364f51c2b8794470ba2e04f136e53be033f (patch)
tree77769038d193608450c2e6c1f507487a8172c2f7
parent657ddf9701519e7bb221e88a0a936a943d5f5ecd (diff)
downloadlibgit2-b67bc364f51c2b8794470ba2e04f136e53be033f.tar.gz
attr_file: fix subdirectory attr case.
Closes #2966.
-rw-r--r--src/attr_file.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 5b008b0e3..c0c99aa18 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -379,6 +379,7 @@ bool git_attr_fnmatch__match(
if ((match->flags & GIT_ATTR_FNMATCH_DIRECTORY) && !path->is_dir) {
int matchval;
+ char *matchpath;
/* for attribute checks or root ignore checks, fail match */
if (!(match->flags & GIT_ATTR_FNMATCH_IGNORE) ||
@@ -388,7 +389,13 @@ bool git_attr_fnmatch__match(
/* for ignore checks, use container of current item for check */
path->basename[-1] = '\0';
flags |= FNM_LEADING_DIR;
- matchval = p_fnmatch(match->pattern, path->path, flags);
+
+ if (match->containing_dir)
+ matchpath = path->basename;
+ else
+ matchpath = path->path;
+
+ matchval = p_fnmatch(match->pattern, matchpath, flags);
path->basename[-1] = '/';
return (matchval != FNM_NOMATCH);
}