summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2012-07-27 18:45:55 +0200
committerVicent Marti <tanoku@gmail.com>2012-07-27 18:45:55 +0200
commitb41a30bdbb96dc0eb2d7e30497918ecbb45fd090 (patch)
tree00c7d7b1883ac812cde389f771d6371c30615d0e /include/git2
parentb84f75c357208ce54c5cc35921ff0b4a1abbe7d2 (diff)
parent786a17cd282cf81c76c45a8e62f2a1003235a673 (diff)
downloadlibgit2-b41a30bdbb96dc0eb2d7e30497918ecbb45fd090.tar.gz
Merge remote-tracking branch 'nulltoken/topic/branch-rework' into development
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/branch.h60
-rw-r--r--include/git2/refs.h21
2 files changed, 52 insertions, 29 deletions
diff --git a/include/git2/branch.h b/include/git2/branch.h
index 8884df15..15894b70 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 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,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 **branch_out,
const char *branch_name,
const git_object *target,
int force);
@@ -97,27 +96,62 @@ GIT_EXTERN(int) git_branch_foreach(
);
/**
- * Move/rename an existing branch reference.
- *
- * @param repo Repository where lives the branch.
+ * Move/rename an existing local branch reference.
*
- * @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);
+/**
+ * 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);
+
+/**
+ * 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
diff --git a/include/git2/refs.h b/include/git2/refs.h
index b119e90b..8dd8e311 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -363,26 +363,15 @@ 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.
+ * Check if a reference is a local branch.
*
- * @param branch_ref A git local branch reference.
+ * @param ref A git reference
*
- * @return 0 on success; GIT_ENOTFOUND when no remote tracking
- * reference exists, otherwise an error code.
+ * @return 1 when the reference lives in the refs/heads
+ * namespace; 0 otherwise.
*/
-GIT_EXTERN(int) git_reference_remote_tracking_from_branch(
- git_reference **tracking_ref,
- git_reference *branch_ref
-);
+GIT_EXTERN(int) git_reference_is_branch(git_reference *ref);
/** @} */
GIT_END_DECL