MCPcopy Create free account
hub / github.com/libgit2/pygit2 / libgit2_callback

Function libgit2_callback

pygit2/callbacks.py:496–514  ·  view source on GitHub ↗
(f: Callable[P, T])

Source from the content-addressed store, hash-verified

494
495
496def libgit2_callback(f: Callable[P, T]) -> Callable[P, T]:
497 @wraps(f)
498 def wrapper(*args):
499 data = ffi.from_handle(args[-1])
500 args = args[:-1] + (data,)
501 try:
502 return f(*args)
503 except Passthrough:
504 # A user defined callback can raise Passthrough to decline to act;
505 # then libgit2 will behave as if there was no callback set in the
506 # first place.
507 return C.GIT_PASSTHROUGH
508 except BaseException as e:
509 # Keep the exception to be re-raised later, and inform libgit2 that
510 # the user defined callback has failed.
511 data._stored_exception = e
512 return C.GIT_EUSER
513
514 return ffi.def_extern()(wrapper) # type: ignore[attr-defined]
515
516
517def libgit2_callback_void(f: Callable[P, T]) -> Callable[P, T]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…