libgit2

git_branch_name

Version:

Get the branch name

Given a reference object, this will check that it really is a branch (ie. it lives under "refs/heads/" or "refs/remotes/"), and return the branch part of it.

Signature

int git_branch_name(const char **out, const git_reference *ref);

Parameters

const char **
In
out

Pointer to the abbreviated reference name. Owned by ref, do not free.

In
ref

A reference object, ideally pointing to a branch

Returns

int

0 on success; GIT_EINVALID if the reference isn't either a local or remote branch, otherwise an error code.

Versions