Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-21 23:45:08 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-21 23:45:08 +0300
commitd96098e966f70afcf6f3bfa1ed1bc20be2672fc8 (patch)
tree9451da684fd52941a3fac74bfe2fe31e018850ab /app/models/repository.rb
parentc378d20c8440aff83a8bd54c5aed9f06a9c205f8 (diff)
Cache head commit and head tree
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 7b8a34eba2c..082ad7a0c6a 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -248,12 +248,20 @@ class Repository
end
def head_commit
- commit(self.root_ref)
+ @head_commit ||= commit(self.root_ref)
+ end
+
+ def head_tree
+ @head_tree ||= Tree.new(self, head_commit.sha, nil)
end
def tree(sha = :head, path = nil)
if sha == :head
- sha = head_commit.sha
+ if path.nil?
+ return head_tree
+ else
+ sha = head_commit.sha
+ end
end
Tree.new(self, sha, path)