diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -929,7 +929,10 @@ int git_config_system(void) int git_config_early(config_fn_t fn, void *data, const char *repo_config) { int ret = 0, found = 0; - const char *home = NULL; + char *xdg_config = NULL; + char *user_config = NULL; + + home_config_paths(&user_config, &xdg_config, "config"); if (git_config_system() && !access(git_etc_gitconfig(), R_OK)) { ret += git_config_from_file(fn, git_etc_gitconfig(), @@ -937,14 +940,14 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config) found += 1; } - home = getenv("HOME"); - if (home) { - char buf[PATH_MAX]; - char *user_config = mksnpath(buf, sizeof(buf), "%s/.gitconfig", home); - if (!access(user_config, R_OK)) { - ret += git_config_from_file(fn, user_config, data); - found += 1; - } + if (!access(xdg_config, R_OK)) { + ret += git_config_from_file(fn, xdg_config, data); + found += 1; + } + + if (!access(user_config, R_OK)) { + ret += git_config_from_file(fn, user_config, data); + found += 1; } if (repo_config && !access(repo_config, R_OK)) { @@ -963,6 +966,8 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config) break; } + free(xdg_config); + free(user_config); return ret == 0 ? found : ret; } |