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

Re: Solaris test failure -- FAIL 61: invalid bool (set)

From
Jeff King <peff@peff.net>
Date
Feb 19, 2008, 23:44 UTC
Message-ID
<20080219234422.GA9987@coredump.intra.peff.net>
In-Reply-To
<8ec76080802191517k5f070d45l497063d93e080272@mail.gmail.com>
On Tue, Feb 19, 2008 at 06:17:42PM -0500, Whit Armstrong wrote:
>         git config --bool bool.nobool foobar
> t1300-repo-config.sh: line -176: 18181 Segmentation Fault      (core
> dumped) git config --bool bool.nobool foobar

Ah. The problem is that we use git_config_int() to parse the command line option which, upon failure, attempts to print a message with config_file_name, which is NULL (since we're not parsing a config file currently). On most systems, printf simply prints "(null)", but on Solaris, it segfaults. But we shouldn't be passing NULL anyway on any system, since it makes the message ugly.

This patch fixes it.

-- >8 -- git_config_*: don't assume we are parsing a config file

These functions get called by other code, including parsing config options from the command line. In that case, config_file_name is NULL, leading to an ugly message or even a segfault on some implementations of printf.

---
diff --git a/config.c b/config.c
index 8064cae..c105c13 100644
--- a/config.c
+++ b/config.c
@@ -280,11 +280,18 @@ int git_parse_ulong(const char *value, unsigned long *ret)
 	return 0;
 }
 
+static void die_bad_config(const char *name)
+{
+	if (config_file_name)
+		die("bad config value '%s' in %s", name, config_file_name);
+	die("bad config value for '%s'", name);
+}
+
 int git_config_int(const char *name, const char *value)
 {
 	long ret;
 	if (!git_parse_long(value, &ret))
-		die("bad config value for '%s' in %s", name, config_file_name);
+		die_bad_config(name);
 	return ret;
 }
 
@@ -292,7 +299,7 @@ unsigned long git_config_ulong(const char *name, const char *value)
 {
 	unsigned long ret;
 	if (!git_parse_ulong(value, &ret))
-		die("bad config value for '%s' in %s", name, config_file_name);
+		die_bad_config(name);
 	return ret;
 }
 
Previous: Johannes SchindelinNext: Jeff King
Message 5 of 9 in “Solaris test failure -- FAIL 61: invalid bool (set)”
  1. Whit ArmstrongFeb 19, 2008
  2. Johannes SchindelinFeb 19, 2008
  3. Whit ArmstrongFeb 19, 2008
  4. Johannes SchindelinFeb 19, 2008
  5. Jeff KingFeb 19, 2008
  6. Jeff KingFeb 19, 2008
  7. Jeff KingFeb 19, 2008
  8. Whit ArmstrongFeb 20, 2008
  9. Jeff KingFeb 20, 2008

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.