summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-05-12 13:06:05 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-05-12 14:36:52 -0400
commitef6d072236bb049480128046932e560e1335cef8 (patch)
tree313fd287324e65813b51fe366f9c478e6bbfccf9
parent9486d203363eeb07166175818fa361e4e5a34015 (diff)
downloadlibgit2-ef6d072236bb049480128046932e560e1335cef8.tar.gz
attr: don't match files for folders
When ignoring a path "foo/", ensure that this is actually a directory, and not simply a file named "foo".
-rw-r--r--src/attr_file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index ef98aacc2..a7cc5916d 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -410,6 +410,14 @@ bool git_attr_fnmatch__match(
else
matchpath = path->path;
+ /* fail match if this is a file with same name as ignored folder */
+ bool samename = (match->flags & GIT_ATTR_FNMATCH_ICASE) ?
+ !strcasecmp(match->pattern, matchpath) :
+ !strcmp(match->pattern, matchpath);
+
+ if (samename)
+ return false;
+
matchval = p_fnmatch(match->pattern, matchpath, flags);
path->basename[-1] = '/';
return (matchval != FNM_NOMATCH);