(cbFile DiffForEachFileCallback, detail DiffDetail)
| 314 | ) |
| 315 | |
| 316 | func (diff *Diff) ForEach(cbFile DiffForEachFileCallback, detail DiffDetail) error { |
| 317 | if diff.ptr == nil { |
| 318 | return ErrInvalid |
| 319 | } |
| 320 | |
| 321 | intHunks := C.int(0) |
| 322 | if detail >= DiffDetailHunks { |
| 323 | intHunks = C.int(1) |
| 324 | } |
| 325 | |
| 326 | intLines := C.int(0) |
| 327 | if detail >= DiffDetailLines { |
| 328 | intLines = C.int(1) |
| 329 | } |
| 330 | |
| 331 | var err error |
| 332 | data := &diffForEachCallbackData{ |
| 333 | fileCallback: cbFile, |
| 334 | errorTarget: &err, |
| 335 | } |
| 336 | |
| 337 | handle := pointerHandles.Track(data) |
| 338 | defer pointerHandles.Untrack(handle) |
| 339 | |
| 340 | runtime.LockOSThread() |
| 341 | defer runtime.UnlockOSThread() |
| 342 | |
| 343 | ret := C._go_git_diff_foreach(diff.ptr, 1, intHunks, intLines, handle) |
| 344 | runtime.KeepAlive(diff) |
| 345 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 346 | return err |
| 347 | } |
| 348 | if ret < 0 { |
| 349 | return MakeGitError(ret) |
| 350 | } |
| 351 | |
| 352 | return nil |
| 353 | } |
| 354 | |
| 355 | //export diffForEachFileCallback |
| 356 | func diffForEachFileCallback(delta *C.git_diff_delta, progress C.float, handle unsafe.Pointer) C.int { |
nothing calls this directly
no test coverage detected