Skip to content

Commit

Permalink
attr: Allow multiple changes to an attribute on the same line.
Browse files Browse the repository at this point in the history
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 <grubba@grubba.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Henrik Grubbström authored and Junio C Hamano committed Apr 11, 2010
1 parent 426c27b commit 969f9d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions t/t0003-attributes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand All @@ -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
'

Expand All @@ -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 &&
Expand Down

0 comments on commit 969f9d7

Please sign in to comment.