{"thread":{"id":"13218","subject":"[PATCH] gitattributes: Fix subdirectory attributes specified from root directory","startedAt":"2008-04-22T18:19:12Z","lastAt":"2008-04-22T18:19:12Z","messageCount":1,"participants":["Matthew Ogilvie"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"74999","messageId":"1208888352-7519-1-git-send-email-mmogilvi_git@miniinfo.net","threadId":"13218","inReplyTo":null,"subject":"[PATCH] gitattributes: Fix subdirectory attributes specified from root directory","fromName":"Matthew Ogilvie","fromEmail":"mmogilvi_git@miniinfo.net","sentAt":"2008-04-22T18:19:12Z","receivedAt":"2008-04-22T18:19:12Z","isPatch":true,"sender":{"key":"mmogilvi_git@miniinfo.net","avatar":null},"body":"Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>\n---\n\nI've been working on adding crlf attribute support for git-cvsserver, and\nnoticed this little issue.  I've included some tests and a fix.\nThe cvsserver stuff is still incomplete and not included.\n\nThere are a couple of things I'm not sure about, but seem to make\nthe most sense the way I coded it:\n\n1. A test of the form \"attr_check /a/i a/i\" (notice the prefixed '/'\nin the pathname) will \"pass\" without this patch, but will not\n\"pass\" with this patch.  This seems slightly more correct, but\nI'm not sure.\n\n2. The first (non-setup) test in t0003-attributes.sh actually\nbatches up several checks as one test.  I figured there should be\nsome limit on how many individual checks get batched into one,\nso I started a second test, but I could see an argument to just\ninclude the new checks in the existing batch.\n\n attr.c                |    4 +++-\n t/t0003-attributes.sh |    8 ++++++++\n 2 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 64b77b1..1a15fad 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -546,7 +546,9 @@ static int path_matches(const char *pathname, int pathlen,\n \t    (baselen && pathname[baselen] != '/') ||\n \t    strncmp(pathname, base, baselen))\n \t\treturn 0;\n-\treturn fnmatch(pattern, pathname + baselen + 1, FNM_PATHNAME) == 0;\n+\tif (baselen != 0)\n+\t\tbaselen++;\n+\treturn fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0;\n }\n \n static int fill_one(const char *what, struct match_attr *a, int rem)\ndiff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh\nindex 3faf135..c56d2fb 100755\n--- a/t/t0003-attributes.sh\n+++ b/t/t0003-attributes.sh\n@@ -21,6 +21,7 @@ test_expect_success 'setup' '\n \tmkdir -p a/b/d a/c &&\n \t(\n \t\techo \"f\ttest=f\"\n+\t\techo \"a/i test=a/i\"\n \t) >.gitattributes &&\n \t(\n \t\techo \"g test=a/g\" &&\n@@ -46,4 +47,11 @@ test_expect_success 'attribute test' '\n \n '\n \n+test_expect_success 'root subdir attribute test' '\n+\n+\tattr_check a/i a/i &&\n+\tattr_check subdir/a/i unspecified\n+\n+'\n+\n test_done\n-- \n1.5.5.1.57.g5909c\n"}]}