git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [RFC/PATCH 1/2] Add a useful return value to git-check-attr
Date: Tue, 17 Apr 2007 10:10:48 +0100	[thread overview]
Message-ID: <200704171010.49168.andyparkins@gmail.com> (raw)

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

             reply	other threads:[~2007-04-17  9:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-17  9:10 Andy Parkins [this message]
2007-04-17  9:28 ` [RFC/PATCH 1/2] Add a useful return value to git-check-attr Junio C Hamano
2007-04-17 10:24   ` Andy Parkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200704171010.49168.andyparkins@gmail.com \
    --to=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).