| 52 | ) |
| 53 | |
| 54 | func (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 | |
| 89 | type Blame struct { |
| 90 | doNotCompare |