X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=config.c;h=625e0518767712583f917762634c2fc852c4d2eb;hb=d3f131b57ec0e69a37bca882fa6bf39aa4c1c387;hp=d73b090b6a60d05b18309755dee4ce3b6e055b2d;hpb=cfa775c10ef698c7b84e2d460d04272993c30da4;p=git.git diff --git a/config.c b/config.c index d73b090b6..625e05187 100644 --- a/config.c +++ b/config.c @@ -852,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. */ @@ -877,12 +876,10 @@ 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) @@ -891,6 +888,18 @@ int git_config(config_fn_t fn, void *data) 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; +} + /* * Find all the stuff for git_config_set() below. */