[libgit2-glib] Added ggit_remote_list()
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Added ggit_remote_list()
- Date: Wed, 13 Jun 2012 15:48:07 +0000 (UTC)
commit 796b16a113c34bc38388a9b2b846e55bc070b02b
Author: Garrett Regier <garrettregier gmail com>
Date: Wed Jun 13 07:40:42 2012 -0700
Added ggit_remote_list()
docs/reference/libgit2-glib-1.0-sections.txt | 2 +
libgit2-glib/ggit-remote.c | 61 ++++++++++++++++++++++++++
libgit2-glib/ggit-remote.h | 5 ++
libgit2-glib/ggit-types.h | 19 ++++++++
4 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/libgit2-glib-1.0-sections.txt b/docs/reference/libgit2-glib-1.0-sections.txt
index 3c703c4..5f3c64d 100644
--- a/docs/reference/libgit2-glib-1.0-sections.txt
+++ b/docs/reference/libgit2-glib-1.0-sections.txt
@@ -433,6 +433,7 @@ ggit_remote_set_fetch_spec
ggit_remote_get_fetch_spec
ggit_remote_set_push_spec
ggit_remote_get_push_spec
+ggit_remote_list
ggit_remote_is_valid_url
ggit_remote_is_supported_url
<SUBSECTION Standard>
@@ -632,6 +633,7 @@ GgitDiffFileCallback
GgitDiffHunkCallback
GgitDiffLineCallback
GgitReferencesCallback
+GgitRemoteListCallback
GgitStatusCallback
GgitSubmoduleCallback
</SECTION>
diff --git a/libgit2-glib/ggit-remote.c b/libgit2-glib/ggit-remote.c
index 485eb43..c2009e9 100644
--- a/libgit2-glib/ggit-remote.c
+++ b/libgit2-glib/ggit-remote.c
@@ -22,6 +22,7 @@
#include "ggit-remote.h"
#include "ggit-error.h"
+#include "ggit-oid.h"
#include "ggit-ref-spec.h"
@@ -303,6 +304,66 @@ ggit_remote_get_push_spec (GgitRemote *remote)
return _ggit_ref_spec_wrap (refspec);
}
+typedef struct {
+ GgitRemoteListCallback callback;
+ gpointer user_data;
+} RemoteListData;
+
+static gint
+remote_list_callback_wrapper (git_remote_head *head,
+ gpointer user_data)
+{
+ RemoteListData *data = user_data;
+ GgitOId *oid;
+ GgitOId *loid;
+ gint ret;
+
+ oid = _ggit_oid_new (&head->oid);
+ loid = _ggit_oid_new (&head->loid);
+
+ ret = data->callback (head->name, oid, loid,
+ head->local, data->user_data);
+
+ ggit_oid_free (loid);
+ ggit_oid_free (oid);
+
+ return ret;
+}
+
+/**
+ * ggit_remote_list:
+ * @remote: a #GgitRemote.
+ * @callback: (scope call) (closure user_data): a #GgitRemoteListCallback.
+ * @user_data: callback user data.
+ * @error: a #GError or %NULL.
+ *
+ * Calls @callback for each ref at @remote.
+ */
+void
+ggit_remote_list (GgitRemote *remote,
+ GgitRemoteListCallback callback,
+ gpointer user_data,
+ GError **error)
+{
+ RemoteListData data;
+ gint ret;
+
+ g_return_if_fail (remote != NULL);
+ g_return_if_fail (callback != NULL);
+ g_return_if_fail (error == NULL || *error == NULL);
+
+ data.callback = callback;
+ data.user_data = user_data;
+
+ ret = git_remote_ls (remote->remote,
+ remote_list_callback_wrapper, &data);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ }
+}
+
/**
* ggit_remote_is_valid_url:
* @url: a url string.
diff --git a/libgit2-glib/ggit-remote.h b/libgit2-glib/ggit-remote.h
index 10c3624..310023d 100644
--- a/libgit2-glib/ggit-remote.h
+++ b/libgit2-glib/ggit-remote.h
@@ -63,6 +63,11 @@ void ggit_remote_set_push_spec (GgitRemote *remot
GError **error);
GgitRefSpec *ggit_remote_get_push_spec (GgitRemote *remote);
+void ggit_remote_list (GgitRemote *remote,
+ GgitRemoteListCallback callback,
+ gpointer user_data,
+ GError **error);
+
gboolean ggit_remote_is_valid_url (const gchar *url);
gboolean ggit_remote_is_supported_url (const gchar *url);
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index c0dff75..be6eba0 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -613,6 +613,25 @@ typedef gint (* GgitReferencesCallback) (const gchar *name,
gpointer data);
/**
+ * GgitRemoteListCallback:
+ * @name: the name of the reference.
+ * @oid: the reference's oid.
+ * @loid: the reference's loid.
+ * @local: if available locally.
+ * @user_data: (closure): user-supplied data.
+ *
+ * The type of the callback functions for listing the references of a
+ * #GgitRemote. See ggit_remote_list().
+ *
+ * Returns: 0 to go continue or a #GgitError in case there was an error.
+ */
+typedef gint (* GgitRemoteListCallback) (const gchar *name,
+ GgitOId *oid,
+ GgitOId *loid,
+ gboolean local,
+ gpointer user_data);
+
+/**
* GgitStatusCallback:
* @path: the file to retrieve status for, rooted at the repository working dir.
* @status_flags: the status value.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]