libgit2

git_odb_read_prefix

Version:

Read an object from the database, given a prefix of its identifier.

This method queries all available ODB backends trying to match the 'len' first hexadecimal characters of the 'short_id'. The remaining (GIT_OID_HEXSZ-len)*4 bits of 'short_id' must be 0s. 'len' must be at least GIT_OID_MINPREFIXLEN, and the prefix must be long enough to identify a unique object in all the backends; the method will fail otherwise.

The returned object is reference counted and internally cached, so it should be closed by the user once it's no longer in use.

Signature

int git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, size_t len);

Parameters

In
out

pointer where to store the read object

In
db

database to search for the object in.

In
short_id

a prefix of the id of the object to read.

size_t
In
len

the length of the prefix

Returns

int

0 if the object was read, GIT_ENOTFOUND if the object is not in the database. GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)

Versions