diff options
| author | Shawn O. Pearce <sop@google.com> | 2008-10-29 15:21:24 -0700 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2008-10-29 15:24:34 -0700 |
| commit | 90be5c0839762d14bdee75d121c3923ed91c8404 (patch) | |
| tree | 9b7381e33f3cf311919f5372c2a34f6a1f337854 /git_config.py | |
| parent | 7965f9fed083f07255d62f2a4a49fb54424356e4 (diff) | |
| download | git-repo-90be5c0839762d14bdee75d121c3923ed91c8404.tar.gz | |
Cache the per-user configuration to avoid duplicate instances
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'git_config.py')
| -rw-r--r-- | git_config.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/git_config.py b/git_config.py index f6c5bd1e..76031a0e 100644 --- a/git_config.py +++ b/git_config.py | |||
| @@ -28,9 +28,13 @@ def IsId(rev): | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | class GitConfig(object): | 30 | class GitConfig(object): |
| 31 | _ForUser = None | ||
| 32 | |||
| 31 | @classmethod | 33 | @classmethod |
| 32 | def ForUser(cls): | 34 | def ForUser(cls): |
| 33 | return cls(file = os.path.expanduser('~/.gitconfig')) | 35 | if cls._ForUser is None: |
| 36 | cls._ForUser = cls(file = os.path.expanduser('~/.gitconfig')) | ||
| 37 | return cls._ForUser | ||
| 34 | 38 | ||
| 35 | @classmethod | 39 | @classmethod |
| 36 | def ForRepository(cls, gitdir, defaults=None): | 40 | def ForRepository(cls, gitdir, defaults=None): |
