Code

git-p4: Cache git config for performance
authorJohn Chapman <thestar@fussycoder.id.au>
Sat, 8 Nov 2008 03:22:49 +0000 (14:22 +1100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Nov 2008 22:50:03 +0000 (14:50 -0800)
This makes git-p4 noticibly faster on Windows.

Signed-off-by: John Chapman <thestar@fussycoder.id.au>
Acked-by: Simon Hausmann <simon@lst.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/fast-import/git-p4

index 38d1a173339d3969fecc20193b31db136d35c7e3..9f0a5f92c1f01f82aba14fbf3b92fd56a1e0674b 100755 (executable)
@@ -316,8 +316,11 @@ def gitBranchExists(branch):
                             stderr=subprocess.PIPE, stdout=subprocess.PIPE);
     return proc.wait() == 0;
 
+_gitConfig = {}
 def gitConfig(key):
-    return read_pipe("git config %s" % key, ignore_error=True).strip()
+    if not _gitConfig.has_key(key):
+        _gitConfig[key] = read_pipe("git config %s" % key, ignore_error=True).strip()
+    return _gitConfig[key]
 
 def p4BranchesInGit(branchesAreInRemotes = True):
     branches = {}