libgit2

git_object_lookup_prefix

Version:

Lookup a reference to one of the objects in a repostory, given a prefix of its identifier (short id).

The object obtained will be so that its identifier matches the first 'len' hexadecimal characters (packets of 4 bits) of the given 'id'. 'len' must be at least GIT_OID_MINPREFIXLEN, and long enough to identify a unique object matching the prefix; otherwise the method will fail.

The generated reference is owned by the repository and should be closed with the git_object_close method instead of free'd manually.

The 'type' parameter must match the type of the object in the odb; the method will fail otherwise. The special value 'GIT_OBJ_ANY' may be passed to let the method guess the object's type.

Signature

int git_object_lookup_prefix(git_object **object_out, git_repository *repo, const git_oid *id, unsigned int len, git_otype type);

Parameters

In
object_out

pointer where to store the looked-up object

In
repo

the repository to look up the object

In
id

a short identifier for the object

unsigned int
In
len

the length of the short identifier

In
type

the type of the object

Returns

int

GIT_SUCCESS or an error code

Versions