Commit ef6d072236bb049480128046932e560e1335cef8

Edward Thomson 2015-05-12T13:06:05

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".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/attr_file.c b/src/attr_file.c
index ef98aac..a7cc591 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);