[libgit2-glib] Bind for ggit_repository_note_foreach
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind for ggit_repository_note_foreach
- Date: Sun, 19 Oct 2014 09:53:19 +0000 (UTC)
commit b9bed9d9d5eb65a19e1ac89c11e7eff4dc7f6f99
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Oct 19 11:52:54 2014 +0200
Bind for ggit_repository_note_foreach
libgit2-glib/ggit-repository.c | 73 ++++++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-repository.h | 6 +++
libgit2-glib/ggit-types.h | 15 ++++++++
3 files changed, 94 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 9492cb6..37b6a99 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -3158,4 +3158,77 @@ ggit_repository_read_note (GgitRepository *repository,
return _ggit_note_wrap (note);
}
+typedef struct
+{
+ gpointer user_data;
+
+ GgitNoteCallback callback;
+} NoteCallbackWrapperData;
+
+static gint
+note_callback_wrapper (const git_oid *blob_id,
+ const git_oid *annotated_object_id,
+ gpointer user_data)
+{
+ NoteCallbackWrapperData *wrapper_data = (NoteCallbackWrapperData *)user_data;
+ GgitOId *gblob_id;
+ GgitOId *gannotated_object_id;
+ gint ret;
+
+ gblob_id = _ggit_oid_wrap (blob_id);
+ gannotated_object_id = _ggit_oid_wrap (annotated_object_id);
+
+ ret = wrapper_data->callback (gblob_id, gannotated_object_id,
+ wrapper_data->user_data);
+ ggit_oid_free (gblob_id);
+ ggit_oid_free (gannotated_object_id);
+
+ return ret;
+}
+
+/**
+ * ggit_repository_note_foreach:
+ * @repository: a #GgitRepository.
+ * @notes_ref: (allow-none): canonical name of the reference to use, or %NULL to use the default ref.
+ * @callback: (scope call): a #GgitNoteCallback.
+ * @user_data: callback user data.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Loop over all the notes within a specified namespace
+ * and issue a callback for each one.
+ * If @callback returns a non-zero value, this will stop looping.
+
+ * Returns: %TRUE if there was no error, %FALSE otherwise.
+ */
+gboolean
+ggit_repository_note_foreach (GgitRepository *repository,
+ const gchar *notes_ref,
+ GgitNoteCallback callback,
+ gpointer user_data,
+ GError **error)
+{
+ NoteCallbackWrapperData wrapper_data;
+ gint ret;
+
+ g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE);
+ g_return_val_if_fail (callback != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ wrapper_data.user_data = user_data;
+ wrapper_data.callback = callback;
+
+ ret = git_note_foreach (_ggit_native_get (repository),
+ notes_ref,
+ note_callback_wrapper,
+ &wrapper_data);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 20cdf84..e331788 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -412,6 +412,12 @@ GgitNote *ggit_repository_read_note (GgitRepository
GgitOId *id,
GError **error);
+gboolean ggit_repository_note_foreach (GgitRepository *repository,
+ const gchar *notes_ref,
+ GgitNoteCallback callback,
+ gpointer user_data,
+ GError **error);
+
G_END_DECLS
#endif /* __GGIT_REPOSITORY_H__ */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 47697f0..3019ecb 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -1192,6 +1192,21 @@ typedef gint (* GgitDiffSimilarityMetricSimilarityCallback) (gint *score,
gpointer user_data);
/**
+ * GgitNoteCallback:
+ * @blob_id: id of the blob containing the message.
+ * @annotated_object_id: id of the git object being annotated.
+ * @user_data: (closure): user-suplied data.
+ *
+ * When iterating over all the notes, callback that will be
+ * issued per note. See ggit_repository_note_foreach().
+ *
+ * Returns: 0 to go continue or a #GgitError in case there was an error.
+ */
+typedef gint (* GgitNoteCallback) (GgitOId *blob_id,
+ GgitOId *annotated_object_id,
+ gpointer user_data);
+
+/**
* GgitReferencesNameCallback:
* @name: the name of the reference
* @user_data: (closure): user-supplied data.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]