From 4878d749f4997a6c8ec6852e63aa9af5fca62a0b Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang <jp_lang@yahoo.fr>
Date: Sat, 20 Feb 2010 13:35:22 +0000
Subject: [PATCH] Do not query git for tags and branches multiple times per
 request.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3467 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
 lib/redmine/scm/adapters/git_adapter.rb | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 604407f5b..d4678b12d 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -33,21 +33,22 @@ module Redmine
         end
 
         def branches
-          branches = []
+          return @branches if @branches
+          @branches = []
           cmd = "#{GIT_BIN} --git-dir #{target('')} branch"
           shellout(cmd) do |io|
             io.each_line do |line|
-              branches << line.match('\s*\*?\s*(.*)$')[1]
+              @branches << line.match('\s*\*?\s*(.*)$')[1]
             end
           end
-          branches.sort!
+          @branches.sort!
         end
 
         def tags
-          tags = []
+          return @tags if @tags
           cmd = "#{GIT_BIN} --git-dir #{target('')} tag"
           shellout(cmd) do |io|
-            io.readlines.sort!.map{|t| t.strip}
+            @tags = io.readlines.sort!.map{|t| t.strip}
           end
         end
 
-- 
GitLab