[libgit2-glib] Update to libgit2 changes
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Update to libgit2 changes
- Date: Mon, 25 Jun 2012 18:36:38 +0000 (UTC)
commit 553dcc25612e46a3b870b2ac9418ae9e4175ae7f
Author: Garrett Regier <garrettregier gmail com>
Date: Mon Jun 25 11:33:54 2012 -0700
Update to libgit2 changes
git_branch_list() was replaced with git_branch_foreach()
docs/reference/libgit2-glib-1.0-sections.txt | 3 +-
libgit2-glib/ggit-repository.c | 43 ++++++++++++-------------
libgit2-glib/ggit-repository.h | 4 ++-
libgit2-glib/ggit-types.h | 16 +++++++++
4 files changed, 42 insertions(+), 24 deletions(-)
---
diff --git a/docs/reference/libgit2-glib-1.0-sections.txt b/docs/reference/libgit2-glib-1.0-sections.txt
index 5f3c64d..042ff8f 100644
--- a/docs/reference/libgit2-glib-1.0-sections.txt
+++ b/docs/reference/libgit2-glib-1.0-sections.txt
@@ -460,7 +460,7 @@ ggit_repository_list_tags
ggit_repository_create_branch
ggit_repository_delete_branch
ggit_repository_move_branch
-ggit_repository_list_branches
+ggit_repository_branches_foreach
ggit_repository_get_remote
ggit_repository_add_remote
ggit_repository_list_remotes
@@ -627,6 +627,7 @@ GgitSortMode
GgitStatusFlags
GgitSubmoduleIgnore
GgitSubmoduleUpdate
+GgitBranchesCallback
GgitConfigCallback
GgitConfigMatchCallback
GgitDiffFileCallback
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index ce16986..96dd8ca 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -1331,43 +1331,42 @@ ggit_repository_move_branch (GgitRepository *repository,
}
}
+typedef gint (* _GitBranchesCallback) (const gchar *branch_name,
+ git_branch_t branch_type,
+ gpointer payload);
+
/**
- * ggit_repository_list_branches:
+ * ggit_repository_branches_foreach:
* @repository: a #GgitRepository.
* @branch_type: a GgitBranchType.
+ * @callback: (scope call): a #GgitBranchesCallback.
+ * @user_data: callback user data.
* @error: a #GError.
*
- * Fill a list with all the branches in the Repository.
- *
- * Returns: (transfer full) (allow-none): a list with the branches specified by @branch_type.
+ * Foreach branch of type @branch_type the callback @callback is called.
**/
-gchar **
-ggit_repository_list_branches (GgitRepository *repository,
- GgitBranchType branch_type,
- GError **error)
+void
+ggit_repository_branches_foreach (GgitRepository *repository,
+ GgitBranchType branch_type,
+ GgitBranchesCallback callback,
+ gpointer user_data,
+ GError **error)
{
gint ret;
- git_strarray branch_names;
- gchar **branches;
- g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_if_fail (GGIT_IS_REPOSITORY (repository));
+ g_return_if_fail (callback != NULL);
+ g_return_if_fail (error == NULL || *error == NULL);
- ret = git_branch_list (&branch_names,
- _ggit_native_get (repository),
- branch_type);
+ ret = git_branch_foreach (_ggit_native_get (repository),
+ branch_type,
+ (_GitBranchesCallback) callback,
+ user_data);
if (ret != GIT_OK)
{
_ggit_error_set (error, ret);
- branches = NULL;
}
- else
- {
- branches = ggit_utils_get_str_array_from_git_strarray (&branch_names);
- }
-
- return branches;
}
/**
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index da5aa1b..2450048 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -137,8 +137,10 @@ void ggit_repository_move_branch (GgitRepository *re
GgitCreateFlags flags,
GError **error);
-gchar **ggit_repository_list_branches (GgitRepository *repository,
+void ggit_repository_branches_foreach (GgitRepository *repository,
GgitBranchType branch_type,
+ GgitBranchesCallback callback,
+ gpointer user_data,
GError **error);
GgitRemote *ggit_repository_get_remote (GgitRepository *repository,
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index be6eba0..a28bf19 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -516,6 +516,22 @@ typedef enum {
/**
+ * GgitBranchesCallback:
+ * @branch_name: the branch name.
+ * @branch_type: a #GgitBranchType.
+ * @user_data: (closure): user-supplied data.
+ *
+ * The type of the callback functions for retrieving the branches
+ * in a #GgitRepository. See ggit_repository_branches_foreach().
+ *
+ * Returns: 0 to go for the next branch or a #GgitError in case there was an error.
+ *
+ */
+typedef gint (* GgitBranchesCallback) (const gchar *branch_name,
+ GgitBranchType branch_type,
+ gpointer user_data);
+
+/**
* GgitConfigCallback:
* @name: the name of the configuration value
* @value: the value
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]