aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-02-20 19:00:32 -0500
committerJunio C Hamano <gitster@pobox.com>2008-02-20 20:21:43 -0800
commitc1867cea90f8e7ee8e1be3fc07a402dde1b2666d (patch)
tree2b87907a3b44e407605ecd7b36756a302c20de36 /config.c
parent9a13ba1bed0e573a7c4523c0c8ed8465c9f341bb (diff)
downloadgit-c1867cea90f8e7ee8e1be3fc07a402dde1b2666d.tar.gz
git-c1867cea90f8e7ee8e1be3fc07a402dde1b2666d.tar.xz
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. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/config.c b/config.c
index 8064cae18..cba2bcfb6 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 for '%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;
}