Class: SimpleGit::Diff

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

Defined Under Namespace

Classes: DiffWrapper

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/diff.rb', line 3

def ptr
  @ptr
end

Instance Method Details

#from_trees(repo, old_tree, new_tree, options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/simple_git/diff.rb', line 5

def from_trees(repo, old_tree, new_tree, options)
  wrapper = DiffWrapper.new
  ret = Git2.git_diff_tree_to_tree(wrapper, repo.ptr, old_tree.ptr, new_tree.ptr, options.ptr)
  if ret != 0
    error = Git2::GitError.new(Git2.giterr_last)
    raise ArgumentError, error[:message].read_string
  end

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

  self
end

#statsObject



19
20
21
# File 'lib/simple_git/diff.rb', line 19

def stats
  @stats ||= DiffStat.new(self)
end