X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=config.c;h=64e41bea22466a81df5eda274bc97e3860d6cde6;hb=ed40a0951cedb70777669144478166aa5bb2cf9c;hp=37385ce9d338ecbd2556cef9455000784ebab7e5;hpb=c214f2c80c70c2a3803bf1f3efc323cee5496024;p=git.git diff --git a/config.c b/config.c index 37385ce9d..64e41bea2 100644 --- a/config.c +++ b/config.c @@ -322,17 +322,30 @@ unsigned long git_config_ulong(const char *name, const char *value) return ret; } -int git_config_bool_or_int(const char *name, const char *value, int *is_bool) +int git_config_maybe_bool(const char *name, const char *value) { - *is_bool = 1; if (!value) return 1; if (!*value) return 0; - if (!strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "on")) + if (!strcasecmp(value, "true") + || !strcasecmp(value, "yes") + || !strcasecmp(value, "on")) return 1; - if (!strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "off")) + if (!strcasecmp(value, "false") + || !strcasecmp(value, "no") + || !strcasecmp(value, "off")) return 0; + return -1; +} + +int git_config_bool_or_int(const char *name, const char *value, int *is_bool) +{ + int v = git_config_maybe_bool(name, value); + if (0 <= v) { + *is_bool = 1; + return v; + } *is_bool = 0; return git_config_int(name, value); } @@ -518,6 +531,11 @@ static int git_default_core_config(const char *var, const char *value) return 0; } + if (!strcmp(var, "core.sparsecheckout")) { + core_apply_sparse_checkout = git_config_bool(var, value); + return 0; + } + /* Add other config variables here and to Documentation/config.txt. */ return 0; } @@ -528,8 +546,7 @@ static int git_default_user_config(const char *var, const char *value) if (!value) return config_error_nonbool(var); strlcpy(git_default_name, value, sizeof(git_default_name)); - if (git_default_email[0]) - user_ident_explicitly_given = 1; + user_ident_explicitly_given |= IDENT_NAME_GIVEN; return 0; } @@ -537,8 +554,7 @@ static int git_default_user_config(const char *var, const char *value) if (!value) return config_error_nonbool(var); strlcpy(git_default_email, value, sizeof(git_default_email)); - if (git_default_name[0]) - user_ident_explicitly_given = 1; + user_ident_explicitly_given |= IDENT_MAIL_GIVEN; return 0; }