From b308c11e4ee7d05df4906e04b4008615f41e069c Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 19 Jul 2012 15:39:16 +0200 Subject: branch: change git_branch_create() to make it return a reference --- include/git2/branch.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/git2/branch.h b/include/git2/branch.h index 8884df15..7442ece0 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -26,9 +26,9 @@ GIT_BEGIN_DECL * this target commit. If `force` is true and a reference * already exists with the given name, it'll be replaced. * - * @param oid_out Pointer where to store the OID of the target commit. + * The returned reference must be freed by the user. * - * @param repo Repository where to store the branch. + * @param ref_out Pointer where to store the underlying reference. * * @param branch_name Name for the branch; this name is * validated for consistency. It should also not conflict with @@ -46,8 +46,7 @@ GIT_BEGIN_DECL * pointing to the provided target commit. */ GIT_EXTERN(int) git_branch_create( - git_oid *oid_out, - git_repository *repo, + git_reference **ref_out, const char *branch_name, const git_object *target, int force); -- cgit v1.2.1 From eed378b66960414942ac78840afbcb19bfffbf15 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 20 Jul 2012 16:19:04 +0200 Subject: branch: introduce git_branch_lookup() --- include/git2/branch.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/git2/branch.h b/include/git2/branch.h index 7442ece0..fb30aaa2 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -117,6 +117,30 @@ GIT_EXTERN(int) git_branch_move( const char *new_branch_name, int force); +/** + * Lookup a branch by its name in a repository. + * + * The generated reference must be freed by the user. + * + * @param branch_out pointer to the looked-up branch reference + * + * @param repo the repository to look up the branch + * + * @param branch_name Name of the branch to be looked-up; + * this name is validated for consistency. + * + * @param branch_type Type of the considered branch. This should + * be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE. + * + * @return 0 on success; GIT_ENOTFOUND when no matching branch + * exists, otherwise an error code. + */ +GIT_EXTERN(int) git_branch_lookup( + git_reference **branch_out, + git_repository *repo, + const char *branch_name, + git_branch_t branch_type); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From 88bcd5153f6dc9e0c7ebc73a1e87c0da17e8df28 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 20 Jul 2012 16:27:56 +0200 Subject: branch: introduce git_reference_is_branch() --- include/git2/refs.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/git2/refs.h b/include/git2/refs.h index b119e90b..ac876ebb 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -384,6 +384,16 @@ GIT_EXTERN(int) git_reference_remote_tracking_from_branch( git_reference *branch_ref ); +/** + * Check if a reference is a local branch. + * + * @param ref A git reference + * + * @return 1 when the reference lives in the refs/heads + * namespace; 0 otherwise. + */ +GIT_EXTERN(int) git_reference_is_branch(git_reference *ref); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From abee7bd36a8a00e9578d3c94b1b7080f5b5c7dc8 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 20 Jul 2012 16:31:17 +0200 Subject: branch: slight git_branch_create() doc improvement --- include/git2/branch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/git2/branch.h b/include/git2/branch.h index fb30aaa2..fcddb933 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -28,7 +28,7 @@ GIT_BEGIN_DECL * * The returned reference must be freed by the user. * - * @param ref_out Pointer where to store the underlying reference. + * @param branch_out Pointer where to store the underlying reference. * * @param branch_name Name for the branch; this name is * validated for consistency. It should also not conflict with @@ -46,7 +46,7 @@ GIT_BEGIN_DECL * pointing to the provided target commit. */ GIT_EXTERN(int) git_branch_create( - git_reference **ref_out, + git_reference **branch_out, const char *branch_name, const git_object *target, int force); -- cgit v1.2.1 From bf9e8cc86b9c32946a395fd12a9b1a5cb71575a9 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 20 Jul 2012 16:34:08 +0200 Subject: branch: make git_branch_move() reference based --- include/git2/branch.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/git2/branch.h b/include/git2/branch.h index fcddb933..724cfba1 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -96,24 +96,19 @@ GIT_EXTERN(int) git_branch_foreach( ); /** - * Move/rename an existing branch reference. + * Move/rename an existing local branch reference. * - * @param repo Repository where lives the branch. - * - * @param old_branch_name Current name of the branch to be moved; - * this name is validated for consistency. + * @param branch Current underlying reference of the branch. * * @param new_branch_name Target name of the branch once the move * is performed; this name is validated for consistency. * * @param force Overwrite existing branch. * - * @return 0 on success, GIT_ENOTFOUND if the branch - * doesn't exist or an error code. + * @return 0 on success, or an error code. */ GIT_EXTERN(int) git_branch_move( - git_repository *repo, - const char *old_branch_name, + git_reference *branch, const char *new_branch_name, int force); -- cgit v1.2.1 From fb910281d6598e2c235f6ec93384d4e08838d655 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 20 Jul 2012 16:38:54 +0200 Subject: branch: introduce git_branch_tracking() --- include/git2/branch.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/git2/branch.h b/include/git2/branch.h index 724cfba1..15894b70 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -136,6 +136,22 @@ GIT_EXTERN(int) git_branch_lookup( const char *branch_name, git_branch_t branch_type); +/** + * Return the reference supporting the remote tracking branch, + * given a local branch reference. + * + * @param tracking_out Pointer where to store the retrieved + * reference. + * + * @param branch Current underlying reference of the branch. + * + * @return 0 on success; GIT_ENOTFOUND when no remote tracking + * reference exists, otherwise an error code. + */ +GIT_EXTERN(int) git_branch_tracking( + git_reference **tracking_out, + git_reference *branch); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From ef4d795ec5f8cd39de72cfbc75565236205833a4 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 20 Jul 2012 16:39:22 +0200 Subject: refs: drop git_reference_remote_tracking_from_branch() --- include/git2/refs.h | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'include') diff --git a/include/git2/refs.h b/include/git2/refs.h index ac876ebb..8dd8e311 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -363,27 +363,6 @@ GIT_EXTERN(int) git_reference_foreach_glob( */ GIT_EXTERN(int) git_reference_has_log(git_reference *ref); - -/** - * Return the reference supporting the remote tracking branch, - * given a reference branch. - * - * The input reference has to be located in the `refs/heads` - * namespace. - * - * @param tracking_ref Pointer where to store the retrieved - * reference. - * - * @param branch_ref A git local branch reference. - * - * @return 0 on success; GIT_ENOTFOUND when no remote tracking - * reference exists, otherwise an error code. - */ -GIT_EXTERN(int) git_reference_remote_tracking_from_branch( - git_reference **tracking_ref, - git_reference *branch_ref -); - /** * Check if a reference is a local branch. * -- cgit v1.2.1