Class: SimpleGit::Diff

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

Defined Under Namespace

Classes: DiffWrapper

Instance Attribute Summary collapse

Class Method 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

Class Method Details

.finalize(ptr) ⇒ Object



21
22
23
# File 'lib/simple_git/diff.rb', line 21

def self.finalize(ptr)
  proc { Git2.git_diff_free(ptr) }
end

Instance Method Details

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



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

def from_trees(repo, old_tree, new_tree, options)
  wrapper = DiffWrapper.new
  Git2.git_diff_tree_to_tree(wrapper, repo.ptr, old_tree.ptr, new_tree.ptr, options.ptr)

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

  self
end

#statsObject



15
16
17
# File 'lib/simple_git/diff.rb', line 15

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