config: be strict on core.commentChar
[gitweb.git] / config.c
index 6821cef00a0da56fbdadbd34d179ba5bd125c3a6..491a9050aebdeff2ca081cf6d6652188c0a77e1d 100644 (file)
--- a/config.c
+++ b/config.c
@@ -557,6 +557,7 @@ int git_parse_ulong(const char *value, unsigned long *ret)
        return 1;
 }
 
+NORETURN
 static void die_bad_number(const char *name, const char *value)
 {
        const char *reason = errno == ERANGE ?
@@ -825,9 +826,13 @@ static int git_default_core_config(const char *var, const char *value)
        if (!strcmp(var, "core.commentchar")) {
                const char *comment;
                int ret = git_config_string(&comment, var, value);
-               if (!ret)
+               if (ret)
+                       return ret;
+               else if (comment[0] && !comment[1]) {
                        comment_line_char = comment[0];
-               return ret;
+               } else
+                       return error("core.commentChar should only be one character");
+               return 0;
        }
 
        if (!strcmp(var, "core.askpass"))