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

Function DiffFromBuffer

diff.go:1087–1103  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1085// will not read unified diffs produced by the diff program, nor any other
1086// types of patch files.
1087func 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}

Callers 1

TestApplyDiffAddfileFunction · 0.85

Calls 3

MakeGitErrorFunction · 0.85
newDiffFromCFunction · 0.85
freeMethod · 0.80

Tested by 1

TestApplyDiffAddfileFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…