git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] buitin_config: return postitive status in get_value

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Jul 28, 2012, 13:29 UTC
Message-ID
<20120728132923.GA31388@do>
In-Reply-To
<CAJg5NvdAq_zEx2phVGS4EiUfqMtFJA2Bo=y1d3FJyWXtzMwCTw@mail.gmail.com>
On Sat, Jul 28, 2012 at 04:18:49PM +0300, Nikolay Vladimirov wrote:
Show 11 quoted lines
> But the behavior now seems kind of strange, or maybe I'm missing something:
> # git config foobar; echo $?
> error: key does not contain a section: foobar
> 255
> 
> # git config foobar.info; echo $?
> 1
> 
> git version 1.7.11.2
> 
> I would generally expect the both to behave the same way.

Then the following patch may be better because it leaves other cases untouched (I'm not saying that we should or should not do it though)

-- 8< --
diff --git a/builtin/config.c b/builtin/config.c
index 8cd08da..d048ebf 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -199,8 +199,10 @@ static int get_value(const char *key_, const char *regex_)
 			goto free_strings;
 		}
 	} else {
-		if (git_config_parse_key(key_, &key, NULL))
+		if (git_config_parse_key(key_, &key, NULL)) {
+			ret = 1;
 			goto free_strings;
+		}
 	}
 
 	if (regex_) {
-- 8< --
-- 
Duy
Previous: Nikolay VladimirovNext: Junio C Hamano
Message 4 of 10 in “buitin_config: return postitive status in get_value”
  1. buitin_config: return postitive status in get_valueNikolai Vladimirov, Jul 28, 2012
  2. Nguyen Thai Ngoc DuyJul 28, 2012
  3. Nikolay VladimirovJul 28, 2012
  4. Nguyen Thai Ngoc DuyJul 28, 2012
  5. Junio C HamanoJul 29, 2012
  6. Junio C HamanoJul 29, 2012
  7. Jeff KingJul 29, 2012
  8. Nguyen Thai Ngoc DuyJul 30, 2012
  9. Junio C HamanoJul 30, 2012
  10. Jeff KingJul 29, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.