gitattributes: Fix subdirectory attributes specified from root directory
[git/git.git] / attr.c
diff --git a/attr.c b/attr.c
index 64b77b1..1a15fad 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -546,7 +546,9 @@ static int path_matches(const char *pathname, int pathlen,
            (baselen && pathname[baselen] != '/') ||
            strncmp(pathname, base, baselen))
                return 0;
-       return fnmatch(pattern, pathname + baselen + 1, FNM_PATHNAME) == 0;
+       if (baselen != 0)
+               baselen++;
+       return fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0;
 }
 
 static int fill_one(const char *what, struct match_attr *a, int rem)