Class: SimpleGit::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_git/tree.rb

Defined Under Namespace

Classes: TreeWrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ptrObject

Returns the value of attribute ptr.



3
4
5
# File 'lib/simple_git/tree.rb', line 3

def ptr
  @ptr
end

Instance Method Details

#from_commit(commit) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# 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