libgit2

git_branch_lookup

Version:

Lookup a branch by its name in a repository.

The generated reference must be freed by the user. The branch name will be checked for validity.

See

  • git_tag_create for rules about valid names.

Signature

int git_branch_lookup(git_reference **out, git_repository *repo, const char *branch_name, git_branch_t branch_type);

Parameters

In
out

pointer to the looked-up branch reference

In
repo

the repository to look up the branch

const char *
In
branch_name

Name of the branch to be looked-up; this name is validated for consistency.

In
branch_type

Type of the considered branch. This should be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.

Returns

int

0 on success; GIT_ENOTFOUND when no matching branch exists, GIT_EINVALIDSPEC, otherwise an error code.

Versions