diff options
author | Sebastian Bauer <mail@sebastianbauer.info> | 2013-01-24 20:44:17 +0100 |
---|---|---|
committer | Sebastian Bauer <mail@sebastianbauer.info> | 2013-01-25 05:24:21 +0100 |
commit | c253056d2429ea0a6201be60921dbac69dbcc98a (patch) | |
tree | 937977952cb53a57ff773597e8b47dac9edcbd48 /include/git2/branch.h | |
parent | 5425097f0368c43e72210c33b844cf7350843c37 (diff) | |
download | libgit2-c253056d2429ea0a6201be60921dbac69dbcc98a.tar.gz |
Added git_branch_name().
This is a convenience function to get the branch name of a given
ref. The returned branch name is compatible with the name that can
be supplied e.g. to git_branch_lookup(). That is, the prefixes
"refs/heads" or "refs/remotes" are omitted.
Also added a new test for testing the new function.
Diffstat (limited to 'include/git2/branch.h')
-rw-r--r-- | include/git2/branch.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/git2/branch.h b/include/git2/branch.h index 70d609ebe..54a1ab118 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -142,6 +142,24 @@ GIT_EXTERN(int) git_branch_lookup( git_branch_t branch_type); /** + * 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. + * + * @param out where the pointer of branch name is stored; + * this is valid as long as the ref is not freed. + * @param ref the reference ideally pointing to a branch + * + * @return 0 on success; otherwise an error code (e.g., if the + * ref is no local or remote branch). + */ +GIT_EXTERN(int) git_branch_name(const char **out, + git_reference *ref); + +/** * Return the reference supporting the remote tracking branch, * given a local branch reference. * |