[libgit2-glib] Bind GgitRebaseOptions



commit 567d3f7823744abd5d3b6d8de552c0a7fe51d2ff
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Aug 14 08:43:01 2015 +0200

    Bind GgitRebaseOptions

 libgit2-glib/Makefile.am           |    2 +
 libgit2-glib/ggit-rebase-options.c |  233 ++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-rebase-options.h |   64 ++++++++++
 libgit2-glib/ggit-types.h          |    7 +
 libgit2-glib/ggit.h.in             |    1 +
 5 files changed, 307 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index 976d18a..d569b90 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -59,6 +59,8 @@ H_FILES =                                     \
        ggit-oid.h                              \
        ggit-patch.h                            \
        ggit-push-options.h                     \
+       ggit-rebase-options.h                   \
+       ggit-rebase-options.c                   \
        ggit-ref.h                              \
        ggit-ref-spec.h                         \
        ggit-reflog.h                           \
diff --git a/libgit2-glib/ggit-rebase-options.c b/libgit2-glib/ggit-rebase-options.c
new file mode 100644
index 0000000..a0ca332
--- /dev/null
+++ b/libgit2-glib/ggit-rebase-options.c
@@ -0,0 +1,233 @@
+/*
+ * ggit-rebase-options.c
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2013 - Ignacio Casal Quinteiro
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ggit-rebase-options.h"
+
+struct _GgitRebaseOptions
+{
+       git_rebase_options rebase_options;
+       gchar *rewrite_notes_ref;
+       GgitCheckoutOptions *checkout_options;
+};
+
+G_DEFINE_BOXED_TYPE (GgitRebaseOptions, ggit_rebase_options,
+                     ggit_rebase_options_copy, ggit_rebase_options_free)
+
+const git_rebase_options *
+_ggit_rebase_options_get_rebase_options (GgitRebaseOptions *rebase_options)
+{
+       /* NULL is common for rebase_options as it specifies to use the default
+        * so handle a NULL rebase_options here instead of in every caller.
+        */
+       if (rebase_options == NULL)
+       {
+               return NULL;
+       }
+
+       return (const git_rebase_options *)&rebase_options->rebase_options;
+}
+
+/**
+ * ggit_rebase_options_copy:
+ * @rebase_options: a #GgitRebaseOptions.
+ *
+ * Copies @rebase_options into a newly allocated #GgitRebaseOptions.
+ *
+ * Returns: (transfer full): a newly allocated #GgitRebaseOptions.
+ */
+GgitRebaseOptions *
+ggit_rebase_options_copy (GgitRebaseOptions *rebase_options)
+{
+       GgitRebaseOptions *new_rebase_options;
+
+       g_return_val_if_fail (rebase_options != NULL, NULL);
+
+       new_rebase_options = g_slice_new0 (GgitRebaseOptions);
+       new_rebase_options->rebase_options = rebase_options->rebase_options;
+
+       ggit_rebase_options_set_quiet (new_rebase_options,
+                                      rebase_options->rebase_options.quiet);
+       ggit_rebase_options_set_rewrite_notes_ref (new_rebase_options,
+                                                  rebase_options->rewrite_notes_ref);
+       ggit_rebase_options_set_checkout_options (new_rebase_options,
+                                                 rebase_options->checkout_options);
+
+       return new_rebase_options;
+}
+
+/**
+ * ggit_rebase_options_free:
+ * @rebase_options: a #GgitRebaseOptions.
+ *
+ * Frees @rebase_options.
+ */
+void
+ggit_rebase_options_free (GgitRebaseOptions *rebase_options)
+{
+       g_return_if_fail (rebase_options != NULL);
+
+       g_free (rebase_options->rewrite_notes_ref);
+       g_clear_object (&rebase_options->checkout_options);
+       g_slice_free (GgitRebaseOptions, rebase_options);
+}
+
+/**
+ * ggit_rebase_options_new:
+ *
+ * Creates a new #GgitRebaseOptions.
+ *
+ * Returns: a newly allocated #GgitRebaseOptions.
+ */
+GgitRebaseOptions *
+ggit_rebase_options_new (void)
+{
+       GgitRebaseOptions *rebase_options;
+       git_rebase_options grebase_options = GIT_REBASE_OPTIONS_INIT;
+
+       rebase_options = g_slice_new0 (GgitRebaseOptions);
+       rebase_options->rebase_options = grebase_options;
+
+       return rebase_options;
+}
+
+/**
+ * ggit_rebase_options_get_quiet:
+ * @rebase_options: a #GgitRebaseOptions.
+ *
+ * Gets whether you want a quiet rebase experience.
+ *
+ * Returns: returns whether you want a quiet rebase experience.
+ */
+gboolean
+ggit_rebase_options_get_quiet (GgitRebaseOptions *rebase_options)
+{
+       g_return_val_if_fail (rebase_options != NULL, FALSE);
+
+       return rebase_options->rebase_options.quiet != 0;
+}
+
+/**
+ * ggit_rebase_options_set_quiet:
+ * @rebase_options: a #GgitRebaseOptions.
+ * @quiet: whether you want a quiet rebase experience.
+ *
+ * Used by ggit_rebase_init(), this will instruct other clients working
+ * on this rebase that you want a quiet rebase experience, which they
+ * may choose to provide in an application-specific manner.  This has no
+ * effect upon libgit2-glib directly, but is provided for interoperability
+ * between Git tools.
+ */
+void
+ggit_rebase_options_set_quiet (GgitRebaseOptions *rebase_options,
+                               gboolean           quiet)
+{
+       g_return_if_fail (rebase_options != NULL);
+
+       rebase_options->rebase_options.quiet = !!quiet;
+}
+
+/**
+ * ggit_rebase_options_get_rewrite_notes_ref:
+ * @rebase_options: a #GgitRebaseOptions.
+ *
+ * Gets the the name of the notes reference used to rewrite notes for rebased
+ * commits when finishing the rebase or %NULL if not set.
+ *
+ * Returns: the name of the notes reference or %NULL.
+ */
+const gchar *
+ggit_rebase_options_get_rewrite_notes_ref (GgitRebaseOptions *rebase_options)
+{
+       g_return_val_if_fail (rebase_options != NULL, NULL);
+
+       return rebase_options->rebase_options.rewrite_notes_ref;
+}
+
+/**
+ * ggit_rebase_options_set_rewrite_notes_ref:
+ * @rebase_options: a #GgitRebaseOptions.
+ * @rewrite_notes_ref: the name of the notes reference.
+ *
+ * Used by ggit_rebase_finish(), this is the name of the notes reference
+ * used to rewrite notes for rebased commits when finishing the rebase;
+ * if %NULL, the contents of the configuration option `notes.rewriteRef`
+ * is examined, unless the configuration option `notes.rewrite.rebase`
+ * is set to false.  If `notes.rewriteRef` is also %NULL, notes will
+ * not be rewritten.
+ */
+void
+ggit_rebase_options_set_rewrite_notes_ref (GgitRebaseOptions *rebase_options,
+                                           const gchar       *rewrite_notes_ref)
+{
+       g_return_if_fail (rebase_options != NULL);
+
+       g_free (rebase_options->rewrite_notes_ref);
+       rebase_options->rewrite_notes_ref = g_strdup (rewrite_notes_ref);
+       rebase_options->rebase_options.rewrite_notes_ref = rebase_options->rewrite_notes_ref;
+}
+
+/**
+ * ggit_rebase_options_get_checkout_options:
+ * @rebase_options: a #GgitRebaseOptions.
+ *
+ * Get the checkout options object or %NULL if not set.
+ *
+ * Returns: (transfer none): the checkout options or %NULL.
+ */
+GgitCheckoutOptions *
+ggit_rebase_options_get_checkout_options (GgitRebaseOptions *rebase_options)
+{
+       g_return_val_if_fail (rebase_options != NULL, NULL);
+       return rebase_options->checkout_options;
+}
+
+/**
+ * ggit_fetch_options_set_checkout_options:
+ * @rebase_options: a #GgitRebaseOptions.
+ * @checkout_options: (allow-none): a #GgitCheckoutOptions or %NULL.
+ *
+ * Set the checkout options object.
+ * Options to control how files are written during ggit_rebase_init(),
+ * ggit_checkout_next() and ggit_checkout_abort(). Note that a minimum
+ * strategy of @GGIT_CHECKOUT_SAFE is defaulted in init and next,
+ * and a minimum strategy of GGIT_CHECKOUT_FORCE is defaulted in
+ * abort to match git semantics.
+ */
+void
+ggit_rebase_options_set_checkout_options (GgitRebaseOptions   *rebase_options,
+                                          GgitCheckoutOptions *checkout_options)
+{
+       g_return_if_fail (rebase_options != NULL);
+
+       g_clear_object (&rebase_options->checkout_options);
+
+       if (checkout_options != NULL)
+       {
+               rebase_options->checkout_options = g_object_ref (checkout_options);
+               rebase_options->rebase_options.checkout_options = 
*_ggit_checkout_options_get_checkout_options (checkout_options);
+       }
+       else
+       {
+               git_checkout_options i = GIT_CHECKOUT_OPTIONS_INIT;
+               rebase_options->rebase_options.checkout_options = i;
+       }
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-rebase-options.h b/libgit2-glib/ggit-rebase-options.h
new file mode 100644
index 0000000..f3d22cd
--- /dev/null
+++ b/libgit2-glib/ggit-rebase-options.h
@@ -0,0 +1,64 @@
+/*
+ * ggit-rebase-options.h
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2015 - Ignacio Casal Quinteiro
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __GGIT_REBASE_OPTIONS_H__
+#define __GGIT_REBASE_OPTIONS_H__
+
+#include <glib-object.h>
+#include <git2.h>
+
+#include "ggit-types.h"
+#include "ggit-checkout-options.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_REBASE_OPTIONS       (ggit_rebase_options_get_type ())
+#define GGIT_REBASE_OPTIONS(obj)       ((GgitRebaseOptions *)obj)
+
+GType                   ggit_rebase_options_get_type                (void) G_GNUC_CONST;
+
+const git_rebase_options *
+                       _ggit_rebase_options_get_rebase_options      (GgitRebaseOptions         
*rebase_options);
+
+GgitRebaseOptions      *ggit_rebase_options_copy                    (GgitRebaseOptions         
*rebase_options);
+void                    ggit_rebase_options_free                    (GgitRebaseOptions         
*rebase_options);
+
+GgitRebaseOptions      *ggit_rebase_options_new                     (void);
+
+gboolean                ggit_rebase_options_get_quiet               (GgitRebaseOptions         
*rebase_options);
+void                    ggit_rebase_options_set_quiet               (GgitRebaseOptions         
*rebase_options,
+                                                                     gboolean                   quiet);
+
+const gchar            *ggit_rebase_options_get_rewrite_notes_ref   (GgitRebaseOptions         
*rebase_options);
+void                    ggit_rebase_options_set_rewrite_notes_ref   (GgitRebaseOptions         
*rebase_options,
+                                                                     const gchar               
*rewrite_notes_ref);
+
+GgitCheckoutOptions    *ggit_rebase_options_get_checkout_options    (GgitRebaseOptions         
*rebase_options);
+void                    ggit_rebase_options_set_checkout_options    (GgitRebaseOptions         
*rebase_options,
+                                                                     GgitCheckoutOptions       
*checkout_options);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRebaseOptions, ggit_rebase_options_free)
+
+G_END_DECLS
+
+#endif /* __GGIT_REBASE_OPTIONS_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index e0b176e..fc8959b 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -173,6 +173,13 @@ typedef struct _GgitOId GgitOId;
 typedef struct _GgitPatch GgitPatch;
 
 /**
+ * GgitRebaseOptions:
+ *
+ * Represents the options used when rebasing.
+ */
+typedef struct _GgitRebaseOptions GgitRebaseOptions;
+
+/**
  * GgitRef:
  *
  * Reprensents a git reference.
diff --git a/libgit2-glib/ggit.h.in b/libgit2-glib/ggit.h.in
index c59ad32..cb82a84 100644
--- a/libgit2-glib/ggit.h.in
+++ b/libgit2-glib/ggit.h.in
@@ -55,6 +55,7 @@
 #include <libgit2-glib/ggit-object.h>
 #include <libgit2-glib/ggit-oid.h>
 #include <libgit2-glib/ggit-patch.h>
+#include <libgit2-glib/ggit-rebase-options.h>
 #include <libgit2-glib/ggit-ref.h>
 #include <libgit2-glib/ggit-reflog-entry.h>
 #include <libgit2-glib/ggit-reflog.h>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]