libgit2

git_reference_foreach

Version:

Perform a callback on each reference in the repository.

Using the list_flags parameter, the references may be filtered by type (GIT_REF_OID or GIT_REF_SYMBOLIC) or using a bitwise OR of git_ref_t values. To include packed refs, include GIT_REF_PACKED. For convenience, use the value GIT_REF_LISTALL to obtain all references, including packed ones.

The callback function will be called for each reference in the repository, receiving the name of the reference and the payload value passed to this method. Returning a non-zero value from the callback will terminate the iteration.

Signature

int git_reference_foreach(git_repository *repo, unsigned int list_flags, git_reference_foreach_cb callback, void *payload);

Parameters

In
repo

Repository where to find the refs

unsigned int
In
list_flags

Filtering flags for the reference listing.

In
callback

Function which will be called for every listed ref

void *
In
payload

Additional data to pass to the callback

Returns

int

0 on success, GIT_EUSER on non-zero callback, or error code

Versions