summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Probst <[email protected]>2015-03-11 16:12:39 -0700
committerMark Probst <[email protected]>2015-03-23 12:02:17 -0700
commit524cc7967be53176108e5c703818ccdd18882100 (patch)
tree0ffe6ae36bbcdca1cd57ec9a0d9fb8515547b600
parent8622831b1128fee96da8a1829b948a49adc3dd6e (diff)
Add DiffIndexToWorkdir
-rw-r--r--diff.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/diff.go b/diff.go
index 54e4a92..23469f2 100644
--- a/diff.go
+++ b/diff.go
@@ -620,3 +620,28 @@ func (v *Repository) DiffTreeToWorkdirWithIndex(oldTree *Tree, opts *DiffOptions
}
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
+}