libgit2

git_oid_shorten_add

Version:

Add a new OID to set of shortened OIDs and calculate the minimal length to uniquely identify all the OIDs in the set.

The OID is expected to be a 40-char hexadecimal string. The OID is owned by the user and will not be modified or freed.

For performance reasons, there is a hard-limit of how many OIDs can be added to a single set (around ~32000, assuming a mostly randomized distribution), which should be enough for any kind of program, and keeps the algorithm fast and memory-efficient.

Attempting to add more than those OIDs will result in a GITERR_INVALID error

Signature

int git_oid_shorten_add(git_oid_shorten *os, const char *text_id);

Parameters

const char *
In
text_id

an OID in text form

Returns

int

the minimal length to uniquely identify all OIDs added so far to the set; or an error code ( < 0) if an error occurs.

Versions