Commit b7b77def931be50777884ddd35a8689df0ecbebd

Russell Belfer 2013-08-09T11:20:49

Match against file with leading ! was too broad

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/pathspec.c b/src/pathspec.c
index 1d7b71a..d56d039 100644
--- a/src/pathspec.c
+++ b/src/pathspec.c
@@ -166,7 +166,8 @@ static int pathspec_match_one(
 	if (result == FNM_NOMATCH &&
 		(match->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 &&
 		*path == '!' &&
-		ctxt->strncomp(path + 1, match->pattern, match->length) == 0)
+		ctxt->strncomp(path + 1, match->pattern, match->length) == 0 &&
+		(!path[match->length + 1] || path[match->length + 1] == '/'))
 		return 1;
 
 	if (result == 0)