From acd82464a11f3c2d3edc1d152d028a142da31a9f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 12 Jan 2015 10:20:23 +0100 Subject: Re-implemented 'user' config level based on suggestion by @jzempel The point is that XDG_CONFIG_HOME is meant to point at the '.config' directory, whereas '.config' has to be added only if HOME is used instead. Fixes #160 --- git/repo/base.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/git/repo/base.py b/git/repo/base.py index c009b9f6..5a93a5a2 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -354,12 +354,8 @@ class Repo(object): if config_level == "system": return "/etc/gitconfig" elif config_level == "user": - for evar in ("XDG_CONFIG_HOME", "HOME"): - if evar not in os.environ: - continue - return os.path.join(os.environ[evar], '.config/git/config') - # end for each evar to check - raise AssertionError("Didn't find a single HOME related environment variable") + config_home = os.environ.get("XDG_CONFIG_HOME") or join(os.environ.get("HOME", '~'), ".config") + return os.path.expanduser(join(config_home, "git", "config")) elif config_level == "global": return os.path.normpath(os.path.expanduser("~/.gitconfig")) elif config_level == "repository": -- cgit v1.2.1