(oldPath, newPath string, oldBuf, newBuf []byte, opts *DiffOptions)
| 67 | } |
| 68 | |
| 69 | func (v *Repository) PatchFromBuffers(oldPath, newPath string, oldBuf, newBuf []byte, opts *DiffOptions) (*Patch, error) { |
| 70 | var patchPtr *C.git_patch |
| 71 | |
| 72 | oldPtr := toPointer(oldBuf) |
| 73 | newPtr := toPointer(newBuf) |
| 74 | |
| 75 | cOldPath := C.CString(oldPath) |
| 76 | defer C.free(unsafe.Pointer(cOldPath)) |
| 77 | |
| 78 | cNewPath := C.CString(newPath) |
| 79 | defer C.free(unsafe.Pointer(cNewPath)) |
| 80 | |
| 81 | var err error |
| 82 | copts := populateDiffOptions(&C.git_diff_options{}, opts, v, &err) |
| 83 | defer freeDiffOptions(copts) |
| 84 | |
| 85 | runtime.LockOSThread() |
| 86 | defer runtime.UnlockOSThread() |
| 87 | |
| 88 | ret := C.git_patch_from_buffers(&patchPtr, oldPtr, C.size_t(len(oldBuf)), cOldPath, newPtr, C.size_t(len(newBuf)), cNewPath, copts) |
| 89 | runtime.KeepAlive(oldBuf) |
| 90 | runtime.KeepAlive(newBuf) |
| 91 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 92 | return nil, err |
| 93 | } |
| 94 | if ret < 0 { |
| 95 | return nil, MakeGitError(ret) |
| 96 | } |
| 97 | |
| 98 | return newPatchFromC(patchPtr), nil |
| 99 | } |
nothing calls this directly
no test coverage detected