diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-10 19:50:14 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-10 19:50:14 +0100 |
commit | 597bc56a32e1b709eefa4e573f11387d04629f0d (patch) | |
tree | 06d1c04995d1c1bb35a29d9d55f7aa05b224a647 | |
parent | becf5efbfc4aee2677e29e1c8cbd756571cb649d (diff) | |
download | gitpython-597bc56a32e1b709eefa4e573f11387d04629f0d.tar.gz |
Added 'user' configuration level.
Fixes #160
-rw-r--r-- | git/repo/base.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index 1dcb80ed..c009b9f6 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -97,7 +97,7 @@ class Repo(object): # invariants # represents the configuration level of a configuration file - config_level = ("system", "global", "repository") + config_level = ("system", "user", "global", "repository") def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=False): """Create a new Repo instance @@ -353,6 +353,13 @@ 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") elif config_level == "global": return os.path.normpath(os.path.expanduser("~/.gitconfig")) elif config_level == "repository": |