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

Method ToBuf

diff.go:446–464  ·  view source on GitHub ↗
(format DiffFormat)

Source from the content-addressed store, hash-verified

444)
445
446func (diff *Diff) ToBuf(format DiffFormat) ([]byte, error) {
447 if diff.ptr == nil {
448 return nil, ErrInvalid
449 }
450
451 diffBuf := C.git_buf{}
452
453 runtime.LockOSThread()
454 defer runtime.UnlockOSThread()
455
456 ecode := C.git_diff_to_buf(&diffBuf, diff.ptr, C.git_diff_format_t(format))
457 runtime.KeepAlive(diff)
458 if ecode < 0 {
459 return nil, MakeGitError(ecode)
460 }
461 defer C.git_buf_dispose(&diffBuf)
462
463 return C.GoBytes(unsafe.Pointer(diffBuf.ptr), C.int(diffBuf.size)), nil
464}
465
466type DiffOptionsFlag int
467

Callers 2

TestApplyDiffAddfileFunction · 0.80
TestApplyToTreeFunction · 0.80

Calls 1

MakeGitErrorFunction · 0.85

Tested by 2

TestApplyDiffAddfileFunction · 0.64
TestApplyToTreeFunction · 0.64