summaryrefslogtreecommitdiff
path: root/diff.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-04-27 23:29:49 +0200
committerCarlos Martín Nieto <[email protected]>2015-04-27 23:29:49 +0200
commitf7781c0e0004f76833c6be93409320b5c143e0c8 (patch)
tree791b5f551780a5fc963316dac4976780def878c3 /diff.go
parent9538c7f750dafaf3752e04b1c1747d7984ca31d0 (diff)
parentb3e7304abf6f0c4ef50e973acb220c40a5ddac86 (diff)
Merge pull request #179 from schani/master
Additions
Diffstat (limited to 'diff.go')
-rw-r--r--diff.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/diff.go b/diff.go
index 63fa867..23469f2 100644
--- a/diff.go
+++ b/diff.go
@@ -595,3 +595,53 @@ func (v *Repository) DiffTreeToWorkdir(oldTree *Tree, opts *DiffOptions) (*Diff,
}
return newDiffFromC(diffPtr), nil
}
+
+func (v *Repository) DiffTreeToWorkdirWithIndex(oldTree *Tree, opts *DiffOptions) (*Diff, error) {
+ var diffPtr *C.git_diff
+ var oldPtr *C.git_tree
+
+ if oldTree != nil {
+ oldPtr = oldTree.cast_ptr
+ }
+
+ copts, notifyData := diffOptionsToC(opts)
+ defer freeDiffOptions(copts)
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ecode := C.git_diff_tree_to_workdir_with_index(&diffPtr, v.ptr, oldPtr, copts)
+ if ecode < 0 {
+ return nil, MakeGitError(ecode)
+ }
+
+ if notifyData != nil && notifyData.Diff != nil {
+ return notifyData.Diff, nil
+ }
+ return newDiffFromC(diffPtr), nil
+}
+
+func (v *Repository) DiffIndexToWorkdir(index *Index, opts *DiffOptions) (*Diff, error) {
+ var diffPtr *C.git_diff
+ var indexPtr *C.git_index
+
+ if index != nil {
+ indexPtr = index.ptr
+ }
+
+ copts, notifyData := diffOptionsToC(opts)
+ defer freeDiffOptions(copts)
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ecode := C.git_diff_index_to_workdir(&diffPtr, v.ptr, indexPtr, copts)
+ if ecode < 0 {
+ return nil, MakeGitError(ecode)
+ }
+
+ if notifyData != nil && notifyData.Diff != nil {
+ return notifyData.Diff, nil
+ }
+ return newDiffFromC(diffPtr), nil
+}