Skip to content

Commit 969f9d7

Browse files
grubbagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 426c27b commit 969f9d7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ static int fill_one(const char *what, struct match_attr *a, int rem)
599599
struct git_attr_check *check = check_all_attr;
600600
int i;
601601

602-
for (i = 0; 0 < rem && i < a->num_attr; i++) {
602+
for (i = a->num_attr - 1; 0 < rem && 0 <= i; i--) {
603603
struct git_attr *attr = a->state[i].attr;
604604
const char **n = &(check[attr->attr_nr].value);
605605
const char *v = a->state[i].setto;

t/t0003-attributes.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ test_expect_success 'setup' '
2222
(
2323
echo "f test=f"
2424
echo "a/i test=a/i"
25+
echo "onoff test -test"
26+
echo "offon -test test"
2527
) >.gitattributes &&
2628
(
2729
echo "g test=a/g" &&
@@ -44,6 +46,8 @@ test_expect_success 'attribute test' '
4446
attr_check b/g unspecified &&
4547
attr_check a/b/h a/b/h &&
4648
attr_check a/b/d/g "a/b/d/*"
49+
attr_check onoff unset
50+
attr_check offon set
4751
4852
'
4953

@@ -58,6 +62,8 @@ a/b/g: test: a/b/g
5862
b/g: test: unspecified
5963
a/b/h: test: a/b/h
6064
a/b/d/g: test: a/b/d/*
65+
onoff: test: unset
66+
offon: test: set
6167
EOF
6268
6369
sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&

0 commit comments

Comments
 (0)