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

[RFC/PATCH 1/2] Add a useful return value to git-check-attr

From
APAndy Parkins <andyparkins@gmail.com>
Date
Apr 17, 2007, 09:10 UTC
Message-ID
<200704171010.49168.andyparkins@gmail.com>

git-check-attr previously always returned success. With this patch it returns success when the requested attribute is found for all supplied paths.

This lets you check in a script whether a file has an attribute:
 $ git-check-attr attribute -- file && echo "file has attribute"
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
This is handy in itself, but I added it to support the tests in the
next patch.
 builtin-check-attr.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin-check-attr.c b/builtin-check-attr.c
index 47b0721..b51c2ae 100644
--- a/builtin-check-attr.c
+++ b/builtin-check-attr.c
@@ -9,6 +9,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
 {
 	struct git_attr_check *check;
 	int cnt, i, doubledash;
+	int allset = 1;
 
 	doubledash = -1;
 	for (i = 1; doubledash < 0 && i < argc; i++) {
@@ -43,7 +44,9 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
 			       (check[j].isset < 0) ? "unspecified" :
 			       (check[j].isset == 0) ? "unset" :
 			       "set");
+			if( check[j].isset <= 0 )
+				allset = 0;
 		}
 	}
-	return 0;
+	return !allset;
 }
-- 
1.5.1.1.821.g88bdb
Next: Junio C Hamano
Message 1 of 3 in “Add a useful return value to git-check-attr”
  1. 1/2 Add a useful return value to git-check-attrAndy Parkins, Apr 17, 2007
  2. Junio C HamanoApr 17, 2007
  3. Andy ParkinsApr 17, 2007

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.