libgit2

git_branch_name

Version:

Return the name of the given local or remote branch.

The name of the branch matches the definition of the name for git_branch_lookup. That is, if the returned name is given to git_branch_lookup() then the reference is returned that was given to this function.

Signature

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

Parameters

const char **
In
out

where the pointer of branch name is stored; this is valid as long as the ref is not freed.

In
ref

the reference ideally pointing to a branch

Returns

int

0 on success; otherwise an error code (e.g., if the ref is no local or remote branch).

Versions