gitattributes: Fix subdirectory attributes specified from root directory
Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthew Ogilvie committed
Apr 22, 2008 at 12:19 UTC
82881b38235d0a46a4486dc5dc819c5d0ee3f2c1
2 files changed
+11
-1
attr.c
+3
-1
@@ -546,7 +546,9 @@ static int path_matches(const char *pathname, int pathlen,
546
(baselen && pathname[baselen] != '/') ||
547
strncmp(pathname, base, baselen))
548
return 0;
549
- return fnmatch(pattern, pathname + baselen + 1, FNM_PATHNAME) == 0;
549
+ if (baselen != 0)
550
+ baselen++;
551
+ return fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0;
552
}
553
554
static int fill_one(const char *what, struct match_attr *a, int rem)
t/t0003-attributes.sh
+8
@@ -21,6 +21,7 @@ test_expect_success 'setup' '
21
mkdir -p a/b/d a/c &&
22
(
23
echo "f test=f"
24
+ echo "a/i test=a/i"
25
) >.gitattributes &&
26
(
27
echo "g test=a/g" &&
@@ -46,4 +47,11 @@ test_expect_success 'attribute test' '
47
48
'
49
50
+test_expect_success 'root subdir attribute test' '
51
+
52
+ attr_check a/i a/i &&
53
+ attr_check subdir/a/i unspecified
54
+
55
+'
56
+
57
test_done