git_config: add support for repo-specific settings
This allows people to write ~/.repoconfig/config akin to ~/.gitconfig
and .repo/config akin to .git/config. This allows us to add settings
specific to repo without mixing up git, and to persist in general.
Change-Id: I1c6fbe31e63fb8ce26aa85335349c6ae5b1712c6
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255832
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
diff --git a/git_config.py b/git_config.py
index 6b1f710..8c4efac 100644
--- a/git_config.py
+++ b/git_config.py
@@ -88,10 +88,12 @@
class GitConfig(object):
_ForUser = None
+ _USER_CONFIG = '~/.gitconfig'
+
@classmethod
def ForUser(cls):
if cls._ForUser is None:
- cls._ForUser = cls(configfile=os.path.expanduser('~/.gitconfig'))
+ cls._ForUser = cls(configfile=os.path.expanduser(cls._USER_CONFIG))
return cls._ForUser
@classmethod
@@ -373,6 +375,12 @@
GitError('git config %s: %s' % (str(args), p.stderr))
+class RepoConfig(GitConfig):
+ """User settings for repo itself."""
+
+ _USER_CONFIG = '~/.repoconfig/config'
+
+
class RefSpec(object):
"""A Git refspec line, split into its components: