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

Method ApplyToTree

diff.go:1053–1074  ·  view source on GitHub ↗

ApplyToTree applies a Diff to a Tree and returns the resulting image as an Index.

(diff *Diff, tree *Tree, opts *ApplyOptions)

Source from the content-addressed store, hash-verified

1051
1052// ApplyToTree applies a Diff to a Tree and returns the resulting image as an Index.
1053func (v *Repository) ApplyToTree(diff *Diff, tree *Tree, opts *ApplyOptions) (*Index, error) {
1054 runtime.LockOSThread()
1055 defer runtime.UnlockOSThread()
1056
1057 var err error
1058 cOpts := populateApplyOptions(&C.git_apply_options{}, opts, &err)
1059 defer freeApplyOptions(cOpts)
1060
1061 var indexPtr *C.git_index
1062 ret := C.git_apply_to_tree(&indexPtr, v.ptr, tree.cast_ptr, diff.ptr, cOpts)
1063 runtime.KeepAlive(diff)
1064 runtime.KeepAlive(tree)
1065 runtime.KeepAlive(cOpts)
1066 if ret == C.int(ErrorCodeUser) && err != nil {
1067 return nil, err
1068 }
1069 if ret < 0 {
1070 return nil, MakeGitError(ret)
1071 }
1072
1073 return newIndexFromC(indexPtr, v), nil
1074}
1075
1076// DiffFromBuffer reads the contents of a git patch file into a Diff object.
1077//

Callers 1

TestApplyToTreeFunction · 0.80

Calls 4

populateApplyOptionsFunction · 0.85
freeApplyOptionsFunction · 0.85
MakeGitErrorFunction · 0.85
newIndexFromCFunction · 0.85

Tested by 1

TestApplyToTreeFunction · 0.64