ApplyToTree applies a Diff to a Tree and returns the resulting image as an Index.
(diff *Diff, tree *Tree, opts *ApplyOptions)
| 1051 | |
| 1052 | // ApplyToTree applies a Diff to a Tree and returns the resulting image as an Index. |
| 1053 | func (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 | // |