diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-18 21:31:51 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-02-20 00:53:39 +0000 |
commit | f841ca48c150e8a62728c5875fb01dcf7c5756a7 (patch) | |
tree | 29983898948da9ada7ea80dd33386cf643fa4c1b /git_config.py | |
parent | c0d1866b35d3e8d0bee3760a9f52574fa2ab8491 (diff) | |
download | git-repo-f841ca48c150e8a62728c5875fb01dcf7c5756a7.tar.gz |
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>
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/git_config.py b/git_config.py index 6b1f7107..8c4efac8 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -88,10 +88,12 @@ def _key(name): | |||
88 | class GitConfig(object): | 88 | class GitConfig(object): |
89 | _ForUser = None | 89 | _ForUser = None |
90 | 90 | ||
91 | _USER_CONFIG = '~/.gitconfig' | ||
92 | |||
91 | @classmethod | 93 | @classmethod |
92 | def ForUser(cls): | 94 | def ForUser(cls): |
93 | if cls._ForUser is None: | 95 | if cls._ForUser is None: |
94 | cls._ForUser = cls(configfile=os.path.expanduser('~/.gitconfig')) | 96 | cls._ForUser = cls(configfile=os.path.expanduser(cls._USER_CONFIG)) |
95 | return cls._ForUser | 97 | return cls._ForUser |
96 | 98 | ||
97 | @classmethod | 99 | @classmethod |
@@ -373,6 +375,12 @@ class GitConfig(object): | |||
373 | GitError('git config %s: %s' % (str(args), p.stderr)) | 375 | GitError('git config %s: %s' % (str(args), p.stderr)) |
374 | 376 | ||
375 | 377 | ||
378 | class RepoConfig(GitConfig): | ||
379 | """User settings for repo itself.""" | ||
380 | |||
381 | _USER_CONFIG = '~/.repoconfig/config' | ||
382 | |||
383 | |||
376 | class RefSpec(object): | 384 | class RefSpec(object): |
377 | """A Git refspec line, split into its components: | 385 | """A Git refspec line, split into its components: |
378 | 386 | ||