Skip to content

Commit

Permalink
gitattributes: Fix subdirectory attributes specified from root directory
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Ogilvie <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Matthew Ogilvie authored and gitster committed Apr 23, 2008
1 parent 29df238 commit 82881b3
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion attr.c
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions t/t0003-attributes.sh
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ test_expect_success 'setup' '
mkdir -p a/b/d a/c &&
(
echo "f test=f"
echo "a/i test=a/i"
) >.gitattributes &&
(
echo "g test=a/g" &&
@@ -46,4 +47,11 @@ test_expect_success 'attribute test' '
'

test_expect_success 'root subdir attribute test' '
attr_check a/i a/i &&
attr_check subdir/a/i unspecified
'

test_done

0 comments on commit 82881b3

Please sign in to comment.