git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH 1/2] Add a useful return value to git-check-attr
@ 2007-04-17  9:10 Andy Parkins
  2007-04-17  9:28 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Parkins @ 2007-04-17  9:10 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH 1/2] Add a useful return value to git-check-attr
  2007-04-17  9:10 [RFC/PATCH 1/2] Add a useful return value to git-check-attr Andy Parkins
@ 2007-04-17  9:28 ` Junio C Hamano
  2007-04-17 10:24   ` Andy Parkins
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-04-17  9:28 UTC (permalink / raw)
  To: Andy Parkins; +Cc: git

Andy Parkins <andyparkins@gmail.com> writes:

> 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"

I wrote check-attr primarily to have a quick way to make sure
the attribute stack is working properly, but I agree making
gitattributes available to scripts is important to make it
useful in general.

And your patch was a step in the right direction based on my
previous patch.

But sorry, you were shooting at a target that is still moving
too fast, and you missed.  It's not your fault, as even I did
not know where it was heading to, but my plan has been to have
the scripts parse the text output, as we would need more than
true/false values, as I did in the four patch series I sent out
tonight.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH 1/2] Add a useful return value to git-check-attr
  2007-04-17  9:28 ` Junio C Hamano
@ 2007-04-17 10:24   ` Andy Parkins
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Parkins @ 2007-04-17 10:24 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

On Tuesday 2007 April 17 10:28, Junio C Hamano wrote:

> And your patch was a step in the right direction based on my
> previous patch.
>
> But sorry, you were shooting at a target that is still moving
> too fast, and you missed.  It's not your fault, as even I did
> not know where it was heading to, but my plan has been to have
> the scripts parse the text output, as we would need more than
> true/false values, as I did in the four patch series I sent out
> tonight.

Not a problem.  It was a couple of seconds work.  I added it so that I could 
test my keyword expansion stuff.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-17 10:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-17  9:10 [RFC/PATCH 1/2] Add a useful return value to git-check-attr Andy Parkins
2007-04-17  9:28 ` Junio C Hamano
2007-04-17 10:24   ` Andy Parkins

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).