DiffFromBuffer reads the contents of a git patch file into a Diff object. The diff object produced is similar to the one that would be produced if you actually produced it computationally by comparing two trees, however there may be subtle differences. For example, a patch file likely contains abbr
(buffer []byte, repo *Repository)
| 1085 | // will not read unified diffs produced by the diff program, nor any other |
| 1086 | // types of patch files. |
| 1087 | func DiffFromBuffer(buffer []byte, repo *Repository) (*Diff, error) { |
| 1088 | var diff *C.git_diff |
| 1089 | |
| 1090 | cBuffer := C.CBytes(buffer) |
| 1091 | defer C.free(unsafe.Pointer(cBuffer)) |
| 1092 | |
| 1093 | runtime.LockOSThread() |
| 1094 | defer runtime.UnlockOSThread() |
| 1095 | |
| 1096 | ecode := C.git_diff_from_buffer(&diff, (*C.char)(cBuffer), C.size_t(len(buffer))) |
| 1097 | if ecode < 0 { |
| 1098 | return nil, MakeGitError(ecode) |
| 1099 | } |
| 1100 | runtime.KeepAlive(diff) |
| 1101 | |
| 1102 | return newDiffFromC(diff, repo), nil |
| 1103 | } |
searching dependent graphs…