{"thread":{"id":"7713","subject":"[RFC/PATCH 1/2] Add a useful return value to git-check-attr","startedAt":"2007-04-17T09:10:48Z","lastAt":"2007-04-17T10:24:37Z","messageCount":3,"participants":["Andy Parkins","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"39621","messageId":"200704171010.49168.andyparkins@gmail.com","threadId":"7713","inReplyTo":null,"subject":"[RFC/PATCH 1/2] Add a useful return value to git-check-attr","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-04-17T09:10:48Z","receivedAt":"2007-04-17T09:10:48Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"git-check-attr previously always returned success.  With this patch it\nreturns success when the requested attribute is found for all supplied\npaths.\n\nThis lets you check in a script whether a file has an attribute:\n\n $ git-check-attr attribute -- file && echo \"file has attribute\"\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\nThis is handy in itself, but I added it to support the tests in the\nnext patch.\n\n builtin-check-attr.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-check-attr.c b/builtin-check-attr.c\nindex 47b0721..b51c2ae 100644\n--- a/builtin-check-attr.c\n+++ b/builtin-check-attr.c\n@@ -9,6 +9,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)\n {\n \tstruct git_attr_check *check;\n \tint cnt, i, doubledash;\n+\tint allset = 1;\n \n \tdoubledash = -1;\n \tfor (i = 1; doubledash < 0 && i < argc; i++) {\n@@ -43,7 +44,9 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)\n \t\t\t       (check[j].isset < 0) ? \"unspecified\" :\n \t\t\t       (check[j].isset == 0) ? \"unset\" :\n \t\t\t       \"set\");\n+\t\t\tif( check[j].isset <= 0 )\n+\t\t\t\tallset = 0;\n \t\t}\n \t}\n-\treturn 0;\n+\treturn !allset;\n }\n-- \n1.5.1.1.821.g88bdb\n"},{"id":"39624","messageId":"7vzm57pcxp.fsf@assigned-by-dhcp.cox.net","threadId":"7713","inReplyTo":"200704171010.49168.andyparkins@gmail.com","subject":"Re: [RFC/PATCH 1/2] Add a useful return value to git-check-attr","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-17T09:28:34Z","receivedAt":"2007-04-17T09:28:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> git-check-attr previously always returned success.  With this patch it\n> returns success when the requested attribute is found for all supplied\n> paths.\n>\n> This lets you check in a script whether a file has an attribute:\n>\n>  $ git-check-attr attribute -- file && echo \"file has attribute\"\n\nI wrote check-attr primarily to have a quick way to make sure\nthe attribute stack is working properly, but I agree making\ngitattributes available to scripts is important to make it\nuseful in general.\n\nAnd your patch was a step in the right direction based on my\nprevious patch.\n\nBut sorry, you were shooting at a target that is still moving\ntoo fast, and you missed.  It's not your fault, as even I did\nnot know where it was heading to, but my plan has been to have\nthe scripts parse the text output, as we would need more than\ntrue/false values, as I did in the four patch series I sent out\ntonight.\n"},{"id":"39633","messageId":"200704171124.39140.andyparkins@gmail.com","threadId":"7713","inReplyTo":"7vzm57pcxp.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC/PATCH 1/2] Add a useful return value to git-check-attr","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-04-17T10:24:37Z","receivedAt":"2007-04-17T10:24:37Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Tuesday 2007 April 17 10:28, Junio C Hamano wrote:\n\n> And your patch was a step in the right direction based on my\n> previous patch.\n>\n> But sorry, you were shooting at a target that is still moving\n> too fast, and you missed.  It's not your fault, as even I did\n> not know where it was heading to, but my plan has been to have\n> the scripts parse the text output, as we would need more than\n> true/false values, as I did in the four patch series I sent out\n> tonight.\n\nNot a problem.  It was a couple of seconds work.  I added it so that I could \ntest my keyword expansion stuff.\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIET\nandyparkins@gmail.com\n"}]}