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; }