From 8622831b1128fee96da8a1829b948a49adc3dd6e Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Wed, 11 Mar 2015 16:12:22 -0700 Subject: [PATCH] Add DiffTreeToWorkdirWithIndex --- diff.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/diff.go b/diff.go index 63fa867..54e4a92 100644 --- a/diff.go +++ b/diff.go @@ -595,3 +595,28 @@ 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 +}