class SimpleGit::Tree

Attributes

ptr[RW]

Private Class Methods

finalize(ptr) click to toggle source
# File lib/simple_git/tree.rb, line 21
def self.finalize(ptr)
  proc { Git2.git_tree_free(ptr) }
end

Public Instance Methods

from_commit(commit) click to toggle source
# File lib/simple_git/tree.rb, line 5
def from_commit(commit)
  wrapper = TreeWrapper.new
  ret = Git2.git_commit_tree(wrapper, commit.ptr)
  if ret != 0
    error = Git2::GitError.new(Git2.giterr_last)
    raise ArgumentError, error[:message].read_string
  end

  @ptr = wrapper[:tree]
  ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))

  self
end