Commit d96098e9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Cache head commit and head tree

parent c378d20c
...@@ -248,13 +248,21 @@ class Repository ...@@ -248,13 +248,21 @@ class Repository
end end
def head_commit 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 end
def tree(sha = :head, path = nil) def tree(sha = :head, path = nil)
if sha == :head if sha == :head
if path.nil?
return head_tree
else
sha = head_commit.sha sha = head_commit.sha
end end
end
Tree.new(self, sha, path) Tree.new(self, sha, path)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment