From 90be5c0839762d14bdee75d121c3923ed91c8404 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 29 Oct 2008 15:21:24 -0700 Subject: [PATCH] Cache the per-user configuration to avoid duplicate instances Signed-off-by: Shawn O. Pearce --- git_config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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): class GitConfig(object): + _ForUser = None + @classmethod def ForUser(cls): - return cls(file = os.path.expanduser('~/.gitconfig')) + if cls._ForUser is None: + cls._ForUser = cls(file = os.path.expanduser('~/.gitconfig')) + return cls._ForUser @classmethod def ForRepository(cls, gitdir, defaults=None):