ApplyDiff appllies a Diff to the given repository, making changes directly in the working directory, the index, or both.
(diff *Diff, location ApplyLocation, opts *ApplyOptions)
| 1028 | // ApplyDiff appllies a Diff to the given repository, making changes directly |
| 1029 | // in the working directory, the index, or both. |
| 1030 | func (v *Repository) ApplyDiff(diff *Diff, location ApplyLocation, opts *ApplyOptions) error { |
| 1031 | runtime.LockOSThread() |
| 1032 | defer runtime.UnlockOSThread() |
| 1033 | |
| 1034 | var err error |
| 1035 | cOpts := populateApplyOptions(&C.git_apply_options{}, opts, &err) |
| 1036 | defer freeApplyOptions(cOpts) |
| 1037 | |
| 1038 | ret := C.git_apply(v.ptr, diff.ptr, C.git_apply_location_t(location), cOpts) |
| 1039 | runtime.KeepAlive(v) |
| 1040 | runtime.KeepAlive(diff) |
| 1041 | runtime.KeepAlive(cOpts) |
| 1042 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 1043 | return err |
| 1044 | } |
| 1045 | if ret < 0 { |
| 1046 | return MakeGitError(ret) |
| 1047 | } |
| 1048 | |
| 1049 | return nil |
| 1050 | } |
| 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) { |