All of lore.kernel.org
 help / color / mirror / Atom feed
* git config --git-all can return non-zero error code
@ 2012-11-19 23:02 Timur Tabi
  2012-11-20  0:10 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Timur Tabi @ 2012-11-19 23:02 UTC (permalink / raw)
  To: git

According to the man page for git-config, the --git-all option is not
supposed to return an error code:

--get-all
	Like get, but does not fail if the number of values for the key is
	not exactly one.

IMHO, zero is also "not exactly one", but I still get a 1 exit code if the
key does not exist.

My .git/config says this:

[user "cq.branch"]
	mastr = upstream/master

git-config --get-all does this:

$ git config --get-all user.cq.branch.master
$ echo $?
1
$ git config --get-all user.cq.branch.mastr
upstream/master
$ echo $?
0

I just want git to return nothing if the key doesn't exist.  I don't want
it to return an exit code.  Is there a way to do this?  I think either the
code is broken or the documentation needs to be changed.

I'm running git version 1.7.3.4

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: git config --git-all can return non-zero error code
  2012-11-19 23:02 git config --git-all can return non-zero error code Timur Tabi
@ 2012-11-20  0:10 ` Junio C Hamano
  2012-11-20  0:24   ` [PATCH] config --get-all: it is an error not to see any value Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2012-11-20  0:10 UTC (permalink / raw)
  To: Timur Tabi; +Cc: git

Timur Tabi <timur@freescale.com> writes:

> According to the man page for git-config, the --git-all option is not
> supposed to return an error code:
>
> --get-all
> 	Like get, but does not fail if the number of values for the key is
> 	not exactly one.
>
> IMHO, zero is also "not exactly one",...

It should have stated "like get, but unlike get, it does not fail
when there are multiple values for the key", but the documentation
was written with that specific knowledge that "--get" has a logic to
make it fail when there are ambiguities, and wanted to stress that
difference.  It forgot to mention their similarity explicitly and
relied on "Like get" part to mean (1) shows the value(s) given to
the key, and (2) it is an error if there is no such key defined.

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

* [PATCH] config --get-all: it is an error not to see any value
  2012-11-20  0:10 ` Junio C Hamano
@ 2012-11-20  0:24   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2012-11-20  0:24 UTC (permalink / raw)
  To: git; +Cc: Timur Tabi

The wording "... is not exactly one." incorrectly hinted as if
having no value is not an error, but that was not what was
intended.  Clarify what similarity it wants to mention by
elaborating the "Like get" part of the description.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-config.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git i/Documentation/git-config.txt w/Documentation/git-config.txt
index eaea079..273239d 100644
--- i/Documentation/git-config.txt
+++ w/Documentation/git-config.txt
@@ -85,8 +85,9 @@ OPTIONS
 	found and error code 2 if multiple key values were found.
 
 --get-all::
-	Like get, but does not fail if the number of values for the key
-	is not exactly one.
+	Like `--get`, shows the value(s) given to the key, and signals an
+	error if there is no such key.  Unlike `--get`, does not
+	fail if there are multiple values defined for the key.
 
 --get-regexp::
 	Like --get-all, but interprets the name as a regular expression and

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

end of thread, other threads:[~2012-11-20  0:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19 23:02 git config --git-all can return non-zero error code Timur Tabi
2012-11-20  0:10 ` Junio C Hamano
2012-11-20  0:24   ` [PATCH] config --get-all: it is an error not to see any value Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.