git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 7/8] attr: Allow multiple changes to an attribute on the same line.

From
Henrik Grubbström (Grubba) <grubba@grubba.org>
Date
Apr 6, 2010, 12:46 UTC
Message-ID
<22e153d1e4258009990f41bd1add1a1d80baff6d.1270554878.git.grubba@grubba.org>
In-Reply-To
<cover.1270554878.git.grubba@grubba.org>

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>
---
NB: Currently the tests in the testsuite patch will have the
opposite meaning, which is probably not what the user expects,
and is contrary to the documentation.
 attr.c                |    2 +-
 t/t0003-attributes.sh |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/attr.c b/attr.c
index 5c6464e..968fb8b 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 1c77192..bd9c8de 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 &&
-- 
1.7.0.3.316.g33b5e
Previous: Henrik Grubbström (Grubba)Next: Henrik Grubbström (Grubba)
Message 13 of 14 in “Attribute and conversion patches”
  1. 0/8 Attribute and conversion patchesHenrik Grubbström (Grubba), Apr 6, 2010
  2. 1/8 convert: Safer handling of $Id$ contraction.Henrik Grubbström (Grubba), Apr 6, 2010
  3. 2/8 convert: Keep foreign $Id$ on checkout.Henrik Grubbström (Grubba), Apr 6, 2010
  4. 3/8 status: Added missing calls to diff_unmodified_pair() in format_callbacks.Henrik Grubbström (Grubba), Apr 6, 2010
  5. Junio C HamanoApr 10, 2010
  6. Henrik GrubbströmApr 12, 2010
  7. Junio C HamanoApr 10, 2010
  8. 4/8 diff: Filter files that have changed only due to conversion changes.Henrik Grubbström (Grubba), Apr 6, 2010
  9. Junio C HamanoApr 10, 2010
  10. Henrik GrubbströmApr 16, 2010
  11. 5/8 convert: Added core.refilteronadd feature.Henrik Grubbström (Grubba), Apr 6, 2010
  12. 6/8 attr: Fixed debug output for macro expansion.Henrik Grubbström (Grubba), Apr 6, 2010
  13. 7/8 attr: Allow multiple changes to an attribute on the same line.Henrik Grubbström (Grubba), Apr 6, 2010
  14. 8/8 attr: Expand macros immediately when encountered.Henrik Grubbström (Grubba), Apr 6, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.