X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=config.c;h=625e0518767712583f917762634c2fc852c4d2eb;hb=baf5aaa33383af656a34b7ba9039e9eb3c9e678c;hp=4b0a82040e7982ab936ed52b2bb3405bc85b80f8;hpb=52c9d8e27592347a03962f47999bd32caf578d0f;p=git.git diff --git a/config.c b/config.c index 4b0a82040..625e05187 100644 --- a/config.c +++ b/config.c @@ -410,7 +410,7 @@ unsigned long git_config_ulong(const char *name, const char *value) return ret; } -int git_config_maybe_bool(const char *name, const char *value) +static int git_config_maybe_bool_text(const char *name, const char *value) { if (!value) return 1; @@ -427,9 +427,19 @@ int git_config_maybe_bool(const char *name, const char *value) return -1; } +int git_config_maybe_bool(const char *name, const char *value) +{ + long v = git_config_maybe_bool_text(name, value); + if (0 <= v) + return v; + if (git_parse_long(value, &v)) + return !!v; + 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); + int v = git_config_maybe_bool_text(name, value); if (0 <= v) { *is_bool = 1; return v; @@ -489,6 +499,13 @@ static int git_default_core_config(const char *var, const char *value) return 0; } + if (!strcmp(var, "core.abbrevguard")) { + unique_abbrev_extra_length = git_config_int(var, value); + if (unique_abbrev_extra_length < 0) + unique_abbrev_extra_length = 0; + return 0; + } + if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; @@ -835,10 +852,9 @@ int git_config_from_parameters(config_fn_t fn, void *data) return 0; } -int git_config(config_fn_t fn, void *data) +int git_config_early(config_fn_t fn, void *data, const char *repo_config) { int ret = 0, found = 0; - char *repo_config = NULL; const char *home = NULL; /* Setting $GIT_CONFIG makes git read _only_ the given config file. */ @@ -860,19 +876,27 @@ int git_config(config_fn_t fn, void *data) free(user_config); } - repo_config = git_pathdup("config"); - if (!access(repo_config, R_OK)) { + if (repo_config && !access(repo_config, R_OK)) { ret += git_config_from_file(fn, repo_config, data); found += 1; } - free(repo_config); ret += git_config_from_parameters(fn, data); if (config_parameters) found += 1; - if (found == 0) - return -1; + return ret == 0 ? found : ret; +} + +int git_config(config_fn_t fn, void *data) +{ + char *repo_config = NULL; + int ret; + + repo_config = git_pathdup("config"); + ret = git_config_early(fn, data, repo_config); + if (repo_config) + free(repo_config); return ret; }