diff options
-rw-r--r-- | attr.c | 3 | ||||
-rwxr-xr-x | t/t0003-attributes.sh | 10 |
2 files changed, 12 insertions, 1 deletions
@@ -573,7 +573,8 @@ static void prepare_attr_stack(const char *path, int dirlen) elem = attr_stack; if (namelen <= dirlen && - !strncmp(elem->origin, path, namelen)) + !strncmp(elem->origin, path, namelen) && + (!namelen || path[namelen] == '/')) break; debug_pop(elem); diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index ebbc7554a7..61b5a2eba6 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -60,6 +60,16 @@ test_expect_success 'attribute test' ' ' +test_expect_success 'prefixes are not confused with leading directories' ' + attr_check a_plus/g unspecified && + cat >expect <<-\EOF && + a/g: test: a/g + a_plus/g: test: unspecified + EOF + git check-attr test a/g a_plus/g >actual && + test_cmp expect actual +' + test_expect_success 'core.attributesfile' ' attr_check global unspecified && git config core.attributesfile "$HOME/global-gitattributes" && |