libgit2

git_reference_normalize_name

Version:

Normalize reference name and check validity.

This will normalize the reference name by removing any leading slash '/' characters and collapsing runs of adjacent slashes between name components into a single slash.

Once normalized, if the reference name is valid, it will be returned in the user allocated buffer.

See git_reference_create_symbolic() for rules about valid names.

Signature

int git_reference_normalize_name(char *buffer_out, size_t buffer_size, const char *name, unsigned int flags);

Parameters

char *
In
buffer_out

User allocated buffer to store normalized name

size_t
In
buffer_size

Size of buffer_out

const char *
In
name

Reference name to be checked.

unsigned int
In
flags

Flags to constrain name validation rules - see the GIT_REF_FORMAT constants above.

Returns

int

0 on success, GIT_EBUFS if buffer is too small, EINVALIDSPEC or an error code.

Versions