[libgit2-glib] Add API to set remote callbacks in clone options
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Add API to set remote callbacks in clone options
- Date: Sat, 23 Nov 2013 00:39:59 +0000 (UTC)
commit d81b8df8575eeedbee418ff539064de9aab3c45e
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sat Nov 23 01:39:48 2013 +0100
Add API to set remote callbacks in clone options
libgit2-glib/ggit-clone-options.c | 53 +++++++++++++++++++++++++++++++++-
libgit2-glib/ggit-clone-options.h | 7 ++++-
libgit2-glib/ggit-remote-callbacks.c | 4 +-
libgit2-glib/ggit-remote-callbacks.h | 4 +-
4 files changed, 62 insertions(+), 6 deletions(-)
---
diff --git a/libgit2-glib/ggit-clone-options.c b/libgit2-glib/ggit-clone-options.c
index 6e63e78..cdc38b2 100644
--- a/libgit2-glib/ggit-clone-options.c
+++ b/libgit2-glib/ggit-clone-options.c
@@ -27,6 +27,7 @@
struct _GgitCloneOptions
{
git_clone_options clone_options;
+ GgitRemoteCallbacks *remote_callbacks;
};
G_DEFINE_BOXED_TYPE (GgitCloneOptions, ggit_clone_options,
@@ -65,12 +66,18 @@ ggit_clone_options_copy (GgitCloneOptions *clone_options)
gclone_options = &clone_options->clone_options;
- new_clone_options = g_slice_new (GgitCloneOptions);
+ new_clone_options = g_slice_new0 (GgitCloneOptions);
gnew_clone_options.bare = gclone_options->bare;
gnew_clone_options.remote_name = g_strdup (gclone_options->remote_name);
gnew_clone_options.checkout_branch = g_strdup (gclone_options->checkout_branch);
+ if (clone_options->remote_callbacks)
+ {
+ new_clone_options->remote_callbacks = g_object_ref (clone_options->remote_callbacks);
+ gnew_clone_options.remote_callbacks = _ggit_remote_callbacks_get_native
(new_clone_options->remote_callbacks);
+ }
+
new_clone_options->clone_options = gnew_clone_options;
return new_clone_options;
@@ -93,6 +100,8 @@ ggit_clone_options_free (GgitCloneOptions *clone_options)
g_free ((gchar *)gclone_options->remote_name);
g_free ((gchar *)gclone_options->checkout_branch);
+ g_clear_object (&clone_options->remote_callbacks);
+
g_slice_free (GgitCloneOptions, clone_options);
}
@@ -212,4 +221,46 @@ ggit_clone_options_set_checkout_branch (GgitCloneOptions *options,
options->clone_options.checkout_branch = g_strdup (checkout_branch);
}
+/**
+ * ggit_clone_options_get_remote_callbacks:
+ * @options: a #GgitCloneOptions.
+ *
+ * Get the remote callbacks object or %NULL if not set.
+ *
+ * Returns: (transfer none): the remote callbacks or %NULL.
+ */
+GgitRemoteCallbacks *
+ggit_clone_options_get_remote_callbacks (GgitCloneOptions *options)
+{
+ g_return_val_if_fail (options != NULL, NULL);
+ return options->remote_callbacks;
+}
+
+/**
+ * ggit_clone_options_set_remote_callbacks:
+ * @options: a #GgitCloneOptions.
+ * @callbacks: (allow-none): a #GgitRemoteCallbacks or %NULL.
+ *
+ * Set the remote callbacks object.
+ */
+void
+ggit_clone_options_set_remote_callbacks (GgitCloneOptions *options,
+ GgitRemoteCallbacks *callbacks)
+{
+ g_return_if_fail (options != NULL);
+
+ g_clear_object (&options->remote_callbacks);
+
+ if (callbacks != NULL)
+ {
+ options->remote_callbacks = g_object_ref (callbacks);
+ options->clone_options.remote_callbacks = _ggit_remote_callbacks_get_native (callbacks);
+ }
+ else
+ {
+ git_remote_callbacks i = GIT_REMOTE_CALLBACKS_INIT;
+ options->clone_options.remote_callbacks = i;
+ }
+}
+
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-clone-options.h b/libgit2-glib/ggit-clone-options.h
index d086138..a6f5c77 100644
--- a/libgit2-glib/ggit-clone-options.h
+++ b/libgit2-glib/ggit-clone-options.h
@@ -25,7 +25,8 @@
#include <glib-object.h>
#include <git2.h>
-#include "ggit-types.h"
+#include <libgit2-glib/ggit-types.h>
+#include <libgit2-glib/ggit-remote-callbacks.h>
G_BEGIN_DECLS
@@ -56,6 +57,10 @@ const gchar *ggit_clone_options_get_checkout_branch (GgitCloneOpti
void ggit_clone_options_set_checkout_branch (GgitCloneOptions *options,
const gchar *checkout_branch);
+GgitRemoteCallbacks *ggit_clone_options_get_remote_callbacks (GgitCloneOptions *options);
+void ggit_clone_options_set_remote_callbacks (GgitCloneOptions *options,
+ GgitRemoteCallbacks *callbacks);
+
G_END_DECLS
#endif /* __GGIT_CLONE_OPTIONS_H__ */
diff --git a/libgit2-glib/ggit-remote-callbacks.c b/libgit2-glib/ggit-remote-callbacks.c
index 7302fb0..84a4afe 100644
--- a/libgit2-glib/ggit-remote-callbacks.c
+++ b/libgit2-glib/ggit-remote-callbacks.c
@@ -176,10 +176,10 @@ ggit_remote_callbacks_init (GgitRemoteCallbacks *self)
self->priv->native.payload = self;
}
-const git_remote_callbacks *
+git_remote_callbacks
_ggit_remote_callbacks_get_native (GgitRemoteCallbacks *self)
{
- return &self->priv->native;
+ return self->priv->native;
}
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-remote-callbacks.h b/libgit2-glib/ggit-remote-callbacks.h
index 8d8e1b9..925d9af 100644
--- a/libgit2-glib/ggit-remote-callbacks.h
+++ b/libgit2-glib/ggit-remote-callbacks.h
@@ -74,9 +74,9 @@ struct _GgitRemoteCallbacksClass
const GgitOId *b);
};
-GType ggit_remote_callbacks_get_type (void) G_GNUC_CONST;
+GType ggit_remote_callbacks_get_type (void) G_GNUC_CONST;
-const git_remote_callbacks *_ggit_remote_callbacks_get_native (GgitRemoteCallbacks *remote_cbs);
+git_remote_callbacks _ggit_remote_callbacks_get_native (GgitRemoteCallbacks *remote_cbs);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]