MCPcopy Create free account
hub / github.com/libgit2/git2go / DiffTreeToIndex

Method DiffTreeToIndex

diff.go:747–778  ·  view source on GitHub ↗
(oldTree *Tree, index *Index, opts *DiffOptions)

Source from the content-addressed store, hash-verified

745}
746
747func (v *Repository) DiffTreeToIndex(oldTree *Tree, index *Index, opts *DiffOptions) (*Diff, error) {
748 var diffPtr *C.git_diff
749 var oldPtr *C.git_tree
750 var indexPtr *C.git_index
751
752 if oldTree != nil {
753 oldPtr = oldTree.cast_ptr
754 }
755
756 if index != nil {
757 indexPtr = index.ptr
758 }
759
760 var err error
761 copts := populateDiffOptions(&C.git_diff_options{}, opts, v, &err)
762 defer freeDiffOptions(copts)
763
764 runtime.LockOSThread()
765 defer runtime.UnlockOSThread()
766
767 ret := C.git_diff_tree_to_index(&diffPtr, v.ptr, oldPtr, indexPtr, copts)
768 runtime.KeepAlive(oldTree)
769 runtime.KeepAlive(index)
770 if ret == C.int(ErrorCodeUser) && err != nil {
771 return nil, err
772 }
773 if ret < 0 {
774 return nil, MakeGitError(ret)
775 }
776
777 return newDiffFromC(diffPtr, v), nil
778}
779
780func (v *Repository) DiffTreeToWorkdirWithIndex(oldTree *Tree, opts *DiffOptions) (*Diff, error) {
781 var diffPtr *C.git_diff

Callers

nothing calls this directly

Calls 4

populateDiffOptionsFunction · 0.85
freeDiffOptionsFunction · 0.85
MakeGitErrorFunction · 0.85
newDiffFromCFunction · 0.85

Tested by

no test coverage detected