Add DiffIndexToWorkdir
This commit is contained in:
parent
8622831b11
commit
524cc7967b
25
diff.go
25
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue