libgit2

git_oid_from_string

Version:

Parse a NUL terminated hex formatted object id string into a git_oid.

The given string must be NUL terminated, and must be the hex size of the given object ID type - 40 characters for SHA1, 64 characters for SHA256.

To parse an incomplete object ID (an object ID prefix), or a sequence of characters that is not NUL terminated, use git_oid_from_prefix.

Signature

int git_oid_from_string(git_oid *out, const char *str, git_oid_t type);

Parameters

In
out

oid structure the result is written into.

const char *
In
str

input hex string

In
type

object id type

Returns

int

0 or an error code

Versions