libgit2

git_branch_remote_name

Version:

Find the remote name of a remote-tracking branch

This will return the name of the remote whose fetch refspec is matching the given branch. E.g. given a branch "refs/remotes/test/master", it will extract the "test" part. If refspecs from multiple remotes match, the function will return GIT_EAMBIGUOUS.

Signature

int git_branch_remote_name(git_buf *out, git_repository *repo, const char *refname);

Parameters

In
out

The buffer into which the name will be written.

In
repo

The repository where the branch lives.

const char *
In
refname

complete name of the remote tracking branch.

Returns

int

0 on success, GIT_ENOTFOUND when no matching remote was found, GIT_EAMBIGUOUS when the branch maps to several remotes, otherwise an error code.

Versions