From 969f9d73228f233aff071a0d07ba28afdb79dbc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Henrik=20Grubbstr=C3=B6m?= Date: Tue, 6 Apr 2010 14:46:43 +0200 Subject: [PATCH] attr: Allow multiple changes to an attribute on the same line. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When using macros it isn't inconceivable to have an attribute being set by a macro, and then being reset explicitly. Signed-off-by: Henrik Grubbström Signed-off-by: Junio C Hamano --- attr.c | 2 +- t/t0003-attributes.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/attr.c b/attr.c index 7dc17b9505..53cf07e913 100644 --- a/attr.c +++ b/attr.c @@ -599,7 +599,7 @@ static int fill_one(const char *what, struct match_attr *a, int rem) struct git_attr_check *check = check_all_attr; int i; - for (i = 0; 0 < rem && i < a->num_attr; i++) { + for (i = a->num_attr - 1; 0 < rem && 0 <= i; i--) { struct git_attr *attr = a->state[i].attr; const char **n = &(check[attr->attr_nr].value); const char *v = a->state[i].setto; diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 1c77192eb3..bd9c8deb4c 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -22,6 +22,8 @@ test_expect_success 'setup' ' ( echo "f test=f" echo "a/i test=a/i" + echo "onoff test -test" + echo "offon -test test" ) >.gitattributes && ( echo "g test=a/g" && @@ -44,6 +46,8 @@ test_expect_success 'attribute test' ' attr_check b/g unspecified && attr_check a/b/h a/b/h && attr_check a/b/d/g "a/b/d/*" + attr_check onoff unset + attr_check offon set ' @@ -58,6 +62,8 @@ a/b/g: test: a/b/g b/g: test: unspecified a/b/h: test: a/b/h a/b/d/g: test: a/b/d/* +onoff: test: unset +offon: test: set EOF sed -e "s/:.*//" < expect | git check-attr --stdin test > actual && -- 2.11.4.GIT