Skip to content

Commit 597bc56

Browse files
committed
Added 'user' configuration level.
Fixes #160
1 parent becf5ef commit 597bc56

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

git/repo/base.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Repo(object):
9797

9898
# invariants
9999
# represents the configuration level of a configuration file
100-
config_level = ("system", "global", "repository")
100+
config_level = ("system", "user", "global", "repository")
101101

102102
def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=False):
103103
"""Create a new Repo instance
@@ -353,6 +353,13 @@ def _get_config_path(self, config_level):
353353

354354
if config_level == "system":
355355
return "/etc/gitconfig"
356+
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")
356363
elif config_level == "global":
357364
return os.path.normpath(os.path.expanduser("~/.gitconfig"))
358365
elif config_level == "repository":

0 commit comments

Comments
 (0)