From 9f8a7c77791ec415475a88016d2bf072028373f9 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 9 Mar 2006 21:53:54 +0000 Subject: [PATCH] Cache the base_dir value for subsequent calls Signed-off-by: Catalin Marinas --- stgit/git.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/stgit/git.py b/stgit/git.py index 40d54ef..351ebbd 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -82,13 +82,21 @@ __commits = dict() # Functions # +# GIT_DIR value cached +__base_dir = None + def get_base_dir(): """Different start-up variables read from the environment """ - if 'GIT_DIR' in os.environ: - return os.environ['GIT_DIR'] - else: - return _output_one_line('git-rev-parse --git-dir') + global __base_dir + + if not __base_dir: + if 'GIT_DIR' in os.environ: + __base_dir = os.environ['GIT_DIR'] + else: + __base_dir = _output_one_line('git-rev-parse --git-dir') + + return __base_dir def get_commit(id_hash): """Commit objects factory. Save/look-up them in the __commits -- 2.11.0