config: be strict on core.commentChar
[gitweb.git] / config.c
index a30cb5c07db18a5ac16c1c98b6600c9fe6dc1b73..491a9050aebdeff2ca081cf6d6652188c0a77e1d 100644 (file)
--- a/config.c
+++ b/config.c
@@ -826,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"))