summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-12 10:20:23 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-12 10:20:23 +0100
commitacd82464a11f3c2d3edc1d152d028a142da31a9f (patch)
treef84c1e76e5e68d65890a99db4c587588028db05b
parente84300df7deed9abf248f79526a5b41fd2f7f76e (diff)
downloadgitpython-acd82464a11f3c2d3edc1d152d028a142da31a9f.tar.gz
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
-rw-r--r--git/repo/base.py8
1 files 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":