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

Method BlameFile

blame.go:54–87  ·  view source on GitHub ↗
(path string, opts *BlameOptions)

Source from the content-addressed store, hash-verified

52)
53
54func (v *Repository) BlameFile(path string, opts *BlameOptions) (*Blame, error) {
55 var blamePtr *C.git_blame
56
57 var copts *C.git_blame_options
58 if opts != nil {
59 copts = &C.git_blame_options{
60 version: C.GIT_BLAME_OPTIONS_VERSION,
61 flags: C.uint32_t(opts.Flags),
62 min_match_characters: C.uint16_t(opts.MinMatchCharacters),
63 min_line: C.size_t(opts.MinLine),
64 max_line: C.size_t(opts.MaxLine),
65 }
66 if opts.NewestCommit != nil {
67 copts.newest_commit = *opts.NewestCommit.toC()
68 }
69 if opts.OldestCommit != nil {
70 copts.oldest_commit = *opts.OldestCommit.toC()
71 }
72 }
73
74 cpath := C.CString(path)
75 defer C.free(unsafe.Pointer(cpath))
76
77 runtime.LockOSThread()
78 defer runtime.UnlockOSThread()
79
80 ecode := C.git_blame_file(&blamePtr, v.ptr, cpath, copts)
81 runtime.KeepAlive(v)
82 if ecode < 0 {
83 return nil, MakeGitError(ecode)
84 }
85
86 return newBlameFromC(blamePtr), nil
87}
88
89type Blame struct {
90 doNotCompare

Callers 1

TestBlameFunction · 0.80

Calls 4

MakeGitErrorFunction · 0.85
newBlameFromCFunction · 0.85
freeMethod · 0.80
toCMethod · 0.45

Tested by 1

TestBlameFunction · 0.64