소스 검색

Cache the per-user configuration to avoid duplicate instances

Signed-off-by: Shawn O. Pearce <sop@google.com>
Shawn O. Pearce 17 년 전
부모
커밋
90be5c0839
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      git_config.py

+ 5 - 1
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):