Skip to content

Commit acd8246

Browse files
committed
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
1 parent e84300d commit acd8246

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

git/repo/base.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,8 @@ def _get_config_path(self, config_level):
354354
if config_level == "system":
355355
return "/etc/gitconfig"
356356
elif config_level == "user":
357-
for evar in ("XDG_CONFIG_HOME", "HOME"):
358-
if evar not in os.environ:
359-
continue
360-
return os.path.join(os.environ[evar], '.config/git/config')
361-
# end for each evar to check
362-
raise AssertionError("Didn't find a single HOME related environment variable")
357+
config_home = os.environ.get("XDG_CONFIG_HOME") or join(os.environ.get("HOME", '~'), ".config")
358+
return os.path.expanduser(join(config_home, "git", "config"))
363359
elif config_level == "global":
364360
return os.path.normpath(os.path.expanduser("~/.gitconfig"))
365361
elif config_level == "repository":

0 commit comments

Comments
 (0)