@matheusbsbs / matheus-bagliano / commits / 969f9d7322
Fork 0

attr: Allow multiple changes to an attribute on the same line.

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>

Henrik Grubbström committed Apr 6, 2010 at 14:46 UTC 969f9d73228f233aff071a0d07ba28afdb79dbc4
2 files changed +7 -1
attr.c
+1 -1
@@ -599,7 +599,7 @@ static int fill_one(const char *what, struct match_attr *a, int rem)
599 struct git_attr_check *check = check_all_attr;
600 int i;
601
602 - for (i = 0; 0 < rem && i < a->num_attr; i++) {
602 + for (i = a->num_attr - 1; 0 < rem && 0 <= i; i--) {
603 struct git_attr *attr = a->state[i].attr;
604 const char **n = &(check[attr->attr_nr].value);
605 const char *v = a->state[i].setto;
t/t0003-attributes.sh
+6
@@ -22,6 +22,8 @@ test_expect_success 'setup' '
22 (
23 echo "f test=f"
24 echo "a/i test=a/i"
25 + echo "onoff test -test"
26 + echo "offon -test test"
27 ) >.gitattributes &&
28 (
29 echo "g test=a/g" &&
@@ -44,6 +46,8 @@ test_expect_success 'attribute test' '
46 attr_check b/g unspecified &&
47 attr_check a/b/h a/b/h &&
48 attr_check a/b/d/g "a/b/d/*"
49 + attr_check onoff unset
50 + attr_check offon set
51
52 '
53
@@ -58,6 +62,8 @@ a/b/g: test: a/b/g
62 b/g: test: unspecified
63 a/b/h: test: a/b/h
64 a/b/d/g: test: a/b/d/*
65 +onoff: test: unset
66 +offon: test: set
67 EOF
68
69 sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&