{"thread":{"id":"23302","subject":"[PATCH 1/2] Attr: Fixed debug output for macro expansion.","startedAt":"2010-04-02T13:53:47Z","lastAt":"2010-04-02T19:23:21Z","messageCount":3,"participants":["Henrik Grubbström (Grubba)","Henrik Grubbström"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"138425","messageId":"ca1f7f974d72a036dd8369309d487bbd047a8e2d.1270216006.git.grubba@grubba.org","threadId":"23302","inReplyTo":null,"subject":"[PATCH 1/2] Attr: Fixed debug output for macro expansion.","fromName":"Henrik Grubbström (Grubba)","fromEmail":"grubba@grubba.org","sentAt":"2010-04-02T13:53:47Z","receivedAt":"2010-04-02T13:53:47Z","isPatch":true,"sender":{"key":"grubba@grubba.org","avatar":"https://avatars.githubusercontent.com/u/1169458?v=4"},"body":"When debug_set() was called during macro expansion, it\nreceived a pointer to a struct git_attr rather than a\nstring.\n\nSigned-off-by: Henrik Grubbström <grubba@grubba.org>\n---\n attr.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex f5346ed..5c6464e 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -605,7 +605,9 @@ static int fill_one(const char *what, struct match_attr *a, int rem)\n \t\tconst char *v = a->state[i].setto;\n \n \t\tif (*n == ATTR__UNKNOWN) {\n-\t\t\tdebug_set(what, a->u.pattern, attr, v);\n+\t\t\tdebug_set(what,\n+\t\t\t\t  a->is_macro?a->u.attr->name:a->u.pattern,\n+\t\t\t\t  attr, v);\n \t\t\t*n = v;\n \t\t\trem--;\n \t\t}\n-- \n1.7.0.3.316.g33b5e\n"},{"id":"138426","messageId":"f02815e3761a8050aa76f46cd19288e72da14206.1270216006.git.grubba@grubba.org","threadId":"23302","inReplyTo":"ca1f7f974d72a036dd8369309d487bbd047a8e2d.1270216006.git.grubba@grubba.org","subject":"[PATCH 2/2] Attr: Allow macros to override earlier attributes.","fromName":"Henrik Grubbström (Grubba)","fromEmail":"grubba@grubba.org","sentAt":"2010-04-02T13:53:48Z","receivedAt":"2010-04-02T13:53:48Z","isPatch":true,"sender":{"key":"grubba@grubba.org","avatar":"https://avatars.githubusercontent.com/u/1169458?v=4"},"body":"Macros need to be able to override earlier attribute values.\nConsider a .gitattributes file with the following content:\n\n[attr]mybinary\tbinary -ident\n*\t\tident\nfoo.bin\t\tmybinary\n\nWithout this patch foo.bin will still have the ident attribute set.\n\nSigned-off-by: Henrik Grubbström <grubba@grubba.org>\n---\n attr.c                |    8 ++++----\n t/t0003-attributes.sh |    6 ++++++\n 2 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 5c6464e..4d7ff02 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -594,7 +594,7 @@ static int path_matches(const char *pathname, int pathlen,\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)\n+static int fill_one(const char *what, struct match_attr *a, int rem, int force)\n {\n \tstruct git_attr_check *check = check_all_attr;\n \tint i;\n@@ -604,7 +604,7 @@ static int fill_one(const char *what, struct match_attr *a, int rem)\n \t\tconst char **n = &(check[attr->attr_nr].value);\n \t\tconst char *v = a->state[i].setto;\n \n-\t\tif (*n == ATTR__UNKNOWN) {\n+\t\tif (force || *n == ATTR__UNKNOWN) {\n \t\t\tdebug_set(what,\n \t\t\t\t  a->is_macro?a->u.attr->name:a->u.pattern,\n \t\t\t\t  attr, v);\n@@ -626,7 +626,7 @@ static int fill(const char *path, int pathlen, struct attr_stack *stk, int rem)\n \t\t\tcontinue;\n \t\tif (path_matches(path, pathlen,\n \t\t\t\t a->u.pattern, base, strlen(base)))\n-\t\t\trem = fill_one(\"fill\", a, rem);\n+\t\t\trem = fill_one(\"fill\", a, rem, 0);\n \t}\n \treturn rem;\n }\n@@ -642,7 +642,7 @@ static int macroexpand(struct attr_stack *stk, int rem)\n \t\t\tcontinue;\n \t\tif (check[a->u.attr->attr_nr].value != ATTR__TRUE)\n \t\t\tcontinue;\n-\t\trem = fill_one(\"expand\", a, rem);\n+\t\trem = fill_one(\"expand\", a, rem, 1);\n \t}\n \treturn rem;\n }\ndiff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh\nindex 1c77192..f8bc43b 100755\n--- a/t/t0003-attributes.sh\n+++ b/t/t0003-attributes.sh\n@@ -20,8 +20,10 @@ test_expect_success 'setup' '\n \n \tmkdir -p a/b/d a/c &&\n \t(\n+\t\techo \"[attr]notest !test\"\n \t\techo \"f\ttest=f\"\n \t\techo \"a/i test=a/i\"\n+\t\techo \"no notest\"\n \t) >.gitattributes &&\n \t(\n \t\techo \"g test=a/g\" &&\n@@ -44,6 +46,8 @@ test_expect_success 'attribute test' '\n \tattr_check b/g unspecified &&\n \tattr_check a/b/h a/b/h &&\n \tattr_check a/b/d/g \"a/b/d/*\"\n+\tattr_check no unspecified\n+\tattr_check a/b/d/no unspecified\n \n '\n \n@@ -58,6 +62,8 @@ a/b/g: test: a/b/g\n b/g: test: unspecified\n a/b/h: test: a/b/h\n a/b/d/g: test: a/b/d/*\n+no: test: unspecified\n+a/b/d/no: test: unspecified\n EOF\n \n \tsed -e \"s/:.*//\" < expect | git check-attr --stdin test > actual &&\n-- \n1.7.0.3.316.g33b5e\n"},{"id":"138450","messageId":"Pine.GSO.4.63.1004022118300.26349@shipon.roxen.com","threadId":"23302","inReplyTo":"f02815e3761a8050aa76f46cd19288e72da14206.1270216006.git.grubba@grubba.org","subject":"Re: [PATCH 2/2] Attr: Allow macros to override earlier attributes.","fromName":"Henrik Grubbström","fromEmail":"grubba@roxen.com","sentAt":"2010-04-02T19:23:21Z","receivedAt":"2010-04-02T19:23:21Z","isPatch":true,"sender":{"key":"grubba@roxen.com","avatar":null},"body":"On Fri, 2 Apr 2010, Henrik Grubbström (Grubba) wrote:\n\n> Macros need to be able to override earlier attribute values.\n> Consider a .gitattributes file with the following content:\n>\n> [attr]mybinary\tbinary -ident\n> *\t\tident\n> foo.bin\t\tmybinary\n>\n> Without this patch foo.bin will still have the ident attribute set.\n\nOn closer thought, the approach taken by this patch wasn't a good idea,\nsince it doesn't handle the case:\n\nbar.bin\t\tmybinary ident\n\n--\nHenrik Grubbström\t\t\t\t\tgrubba@roxen.com\nRoxen Internet Software AB"}]}