Code

i18n: git-submodule "cached cannot be used" message
[git.git] / config.c
index fa740a6a60a49512b613f70add97d445f622afd2..5f9ec2894570d23f8b91327374a4d82dd46cbca3 100644 (file)
--- a/config.c
+++ b/config.c
@@ -133,23 +133,21 @@ static int get_next_char(void)
 
 static char *parse_value(void)
 {
-       static char value[1024];
-       int quote = 0, comment = 0, len = 0, space = 0;
+       static struct strbuf value = STRBUF_INIT;
+       int quote = 0, comment = 0, space = 0;
 
+       strbuf_reset(&value);
        for (;;) {
                int c = get_next_char();
-               if (len >= sizeof(value) - 1)
-                       return NULL;
                if (c == '\n') {
                        if (quote)
                                return NULL;
-                       value[len] = 0;
-                       return value;
+                       return value.buf;
                }
                if (comment)
                        continue;
                if (isspace(c) && !quote) {
-                       if (len)
+                       if (value.len)
                                space++;
                        continue;
                }
@@ -160,7 +158,7 @@ static char *parse_value(void)
                        }
                }
                for (; space; space--)
-                       value[len++] = ' ';
+                       strbuf_addch(&value, ' ');
                if (c == '\\') {
                        c = get_next_char();
                        switch (c) {
@@ -182,14 +180,14 @@ static char *parse_value(void)
                        default:
                                return NULL;
                        }
-                       value[len++] = c;
+                       strbuf_addch(&value, c);
                        continue;
                }
                if (c == '"') {
                        quote = 1-quote;
                        continue;
                }
-               value[len++] = c;
+               strbuf_addch(&value, c);
        }
 }
 
@@ -523,6 +521,14 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.abbrev")) {
+               int abbrev = git_config_int(var, value);
+               if (abbrev < minimum_abbrev || abbrev > 40)
+                       return -1;
+               default_abbrev = abbrev;
+               return 0;
+       }
+
        if (!strcmp(var, "core.loosecompression")) {
                int level = git_config_int(var, value);
                if (level == -1)
@@ -559,6 +565,12 @@ static int git_default_core_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "core.bigfilethreshold")) {
+               long n = git_config_int(var, value);
+               big_file_threshold = 0 < n ? n : 0;
+               return 0;
+       }
+
        if (!strcmp(var, "core.packedgitlimit")) {
                packed_git_limit = git_config_int(var, value);
                return 0;
@@ -825,11 +837,6 @@ int git_config_system(void)
        return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
 }
 
-int git_config_global(void)
-{
-       return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
-}
-
 int git_config_from_parameters(config_fn_t fn, void *data)
 {
        static int loaded_environment;
@@ -861,7 +868,7 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
        }
 
        home = getenv("HOME");
-       if (git_config_global() && home) {
+       if (home) {
                char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
                if (!access(user_config, R_OK)) {
                        ret += git_config_from_file(fn, user_config, data);