# git config --git-all can return non-zero error code

3 messages from 2012-11-19 to 2012-11-20. Participants: Timur Tabi, Junio C Hamano.
Thread: https://gitlist.dev/t/32148

## Timur Tabi, 2012-11-19 23:02

Subject: git config --git-all can return non-zero error code
Message-ID: <50AABA9B.6090007@freescale.com>
URL: https://gitlist.dev/e/50AABA9B.6090007%40freescale.com

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

```

## Junio C Hamano, 2012-11-20 00:10

Subject: Re: git config --git-all can return non-zero error code
Message-ID: <7vd2z9uobn.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vd2z9uobn.fsf%40alter.siamese.dyndns.org
In-Reply-To: <50AABA9B.6090007@freescale.com>

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

```

## Junio C Hamano, 2012-11-20 00:24

Subject: [PATCH] config --get-all: it is an error not to see any value
Message-ID: <7v7gphunoc.fsf_-_@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7gphunoc.fsf_-_%40alter.siamese.dyndns.org
In-Reply-To: <7vd2z9uobn.fsf@alter.siamese.dyndns.org>

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

```
