login
Header Space

 
 

[PATCH 1/3] git_config_*: don't assume we are parsing a config file

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: Whit Armstrong <armstrong.whit@...>, <git@...>
Date: Wednesday, February 20, 2008 - 8:00 pm

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>
---
 config.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/config.c b/config.c
index 8064cae..cba2bcf 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;
 }
 
-- 
1.5.4.2.247.g107bd

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3] solaris test results, Jeff King, (Wed Feb 20, 7:59 pm)
Re: [PATCH 0/3] solaris test results, Junio C Hamano, (Wed Feb 20, 8:34 pm)
Re: [PATCH 0/3] solaris test results, Jeff King, (Wed Feb 20, 8:41 pm)
[PATCH 1/3] git_config_*: don't assume we are parsing a conf..., Jeff King, (Wed Feb 20, 8:00 pm)
speck-geostationary