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

Method ForEach

diff.go:316–353  ·  view source on GitHub ↗
(cbFile DiffForEachFileCallback, detail DiffDetail)

Source from the content-addressed store, hash-verified

314)
315
316func (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
356func diffForEachFileCallback(delta *C.git_diff_delta, progress C.float, handle unsafe.Pointer) C.int {

Callers

nothing calls this directly

Calls 3

MakeGitErrorFunction · 0.85
TrackMethod · 0.80
UntrackMethod · 0.80

Tested by

no test coverage detected