[libgit2-glib] Bind GgitRebaseOperation
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind GgitRebaseOperation
- Date: Wed, 26 Aug 2015 06:46:46 +0000 (UTC)
commit c65653720ce025f1eb0eccda9c2d562780e77b9c
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Aug 25 21:43:37 2015 +0200
Bind GgitRebaseOperation
libgit2-glib/Makefile.am | 2 +
libgit2-glib/ggit-rebase-operation.c | 141 ++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-rebase-operation.h | 56 +++++++++++++
libgit2-glib/ggit-types.h | 7 ++
4 files changed, 206 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index d063d5c..9dc4327 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -60,6 +60,7 @@ H_FILES = \
ggit-oid.h \
ggit-patch.h \
ggit-push-options.h \
+ ggit-rebase-operation.h \
ggit-rebase-options.h \
ggit-ref.h \
ggit-ref-spec.h \
@@ -129,6 +130,7 @@ C_FILES = \
ggit-oid.c \
ggit-patch.c \
ggit-push-options.c \
+ ggit-rebase-operation.c \
ggit-rebase-options.c \
ggit-ref.c \
ggit-ref-spec.c \
diff --git a/libgit2-glib/ggit-rebase-operation.c b/libgit2-glib/ggit-rebase-operation.c
new file mode 100644
index 0000000..266d489
--- /dev/null
+++ b/libgit2-glib/ggit-rebase-operation.c
@@ -0,0 +1,141 @@
+/*
+ * ggit-rebase-operation.c
+ * 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/>.
+ */
+
+#include <git2.h>
+
+#include "ggit-rebase-operation.h"
+#include "ggit-oid.h"
+
+struct _GgitRebaseOperation
+{
+ gint ref_count;
+
+ git_rebase_operation *rebase_operation;
+};
+
+G_DEFINE_BOXED_TYPE (GgitRebaseOperation, ggit_rebase_operation,
+ ggit_rebase_operation_ref, ggit_rebase_operation_unref)
+
+GgitRebaseOperation *
+_ggit_rebase_operation_wrap (git_rebase_operation *rebase_operation)
+{
+ GgitRebaseOperation *glib_rebase_operation;
+
+ glib_rebase_operation = g_slice_new (GgitRebaseOperation);
+ glib_rebase_operation->ref_count = 1;
+ glib_rebase_operation->rebase_operation = rebase_operation;
+
+ return glib_rebase_operation;
+}
+
+git_rebase_operation *
+_ggit_rebase_operation_get_rebase_operation (GgitRebaseOperation *rebase_operation)
+{
+ return rebase_operation->rebase_operation;
+}
+
+/**
+ * ggit_rebase_operation_ref:
+ * @rebase_operation: a #GgitRebaseOperation.
+ *
+ * Atomically increments the reference count of @rebase_operation by one.
+ * This function is MT-safe and may be called from any thread.
+ *
+ * Returns: (transfer none): a newly allocated #GgitRebaseOperation.
+ */
+GgitRebaseOperation *
+ggit_rebase_operation_ref (GgitRebaseOperation *rebase_operation)
+{
+ g_return_val_if_fail (rebase_operation != NULL, NULL);
+
+ g_atomic_int_inc (&rebase_operation->ref_count);
+
+ return rebase_operation;
+}
+
+/**
+ * ggit_rebase_operation_unref:
+ * @rebase_operation: a #GgitRebaseOperation.
+ *
+ * Atomically decrements the reference count of @rebase_operation by one.
+ * If the reference count drops to 0, @rebase_operation is freed.
+ */
+void
+ggit_rebase_operation_unref (GgitRebaseOperation *rebase_operation)
+{
+ g_return_if_fail (rebase_operation != NULL);
+
+ if (g_atomic_int_dec_and_test (&rebase_operation->ref_count))
+ {
+ g_slice_free (GgitRebaseOperation, rebase_operation);
+ }
+}
+
+/**
+ * ggit_rebase_operation_get_operation_type:
+ * @rebase_operation: a #GgitRebaseOperation.
+ *
+ * Gets the type of rebase operation.
+ *
+ * Returns: a #GgitRebaseOperationType.
+ */
+GgitRebaseOperationType
+ggit_rebase_operation_get_operation_type (GgitRebaseOperation *rebase_operation)
+{
+ g_return_val_if_fail (rebase_operation != NULL, 0);
+
+ return (GgitRebaseOperationType)rebase_operation->rebase_operation->type;
+}
+
+/**
+ * ggit_rebase_operation_get_id:
+ * @rebase_operation: a #GgitRebaseOperation.
+ *
+ * Gets the commit ID being cherry-picked. This will be populated for
+ * all operations except those of type @GGIT_REBASE_OPERATION_EXEC.
+ *
+ * Returns: (transfer full): the commit ID being cherry-picked.
+ */
+GgitOId *
+ggit_rebase_operation_get_id (GgitRebaseOperation *rebase_operation)
+{
+ g_return_val_if_fail (rebase_operation != NULL, NULL);
+
+ return _ggit_oid_wrap ((git_oid *)&rebase_operation->rebase_operation->id);
+}
+
+/**
+ * ggit_rebase_operation_get_exec:
+ * @rebase_operation: a #GgitRebaseOperation.
+ *
+ * Gets the executable the user has requested be run. This will only
+ * be populated for operations of type @GGIT_REBASE_OPERATION_EXEC.
+ *
+ * Returns: the executable the user has requested be run.
+ */
+const gchar *
+ggit_rebase_operation_get_exec (GgitRebaseOperation *rebase_operation)
+{
+ g_return_val_if_fail (rebase_operation != NULL, NULL);
+
+ return rebase_operation->rebase_operation->exec;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-rebase-operation.h b/libgit2-glib/ggit-rebase-operation.h
new file mode 100644
index 0000000..20d829a
--- /dev/null
+++ b/libgit2-glib/ggit-rebase-operation.h
@@ -0,0 +1,56 @@
+/*
+ * ggit-rebase-operation.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_OPERATION_H__
+#define __GGIT_REBASE_OPERATION_H__
+
+#include <glib-object.h>
+#include <git2.h>
+
+#include "ggit-types.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_REBASE_OPERATION (ggit_rebase_operation_get_type ())
+#define GGIT_REBASE_OPERATION(obj) ((GgitRebaseOperation *)obj)
+
+GType ggit_rebase_operation_get_type (void) G_GNUC_CONST;
+
+GgitRebaseOperation *_ggit_rebase_operation_wrap (git_rebase_operation
*rebase_operation);
+
+git_rebase_operation *_ggit_rebase_operation_get_rebase_operation (GgitRebaseOperation
*rebase_operation);
+
+GgitRebaseOperation *ggit_rebase_operation_ref (GgitRebaseOperation
*rebase_operation);
+void ggit_rebase_operation_unref (GgitRebaseOperation
*rebase_operation);
+
+GgitRebaseOperationType ggit_rebase_operation_get_operation_type (GgitRebaseOperation
*rebase_operation);
+
+GgitOId *ggit_rebase_operation_get_id (GgitRebaseOperation
*rebase_operation);
+
+const gchar *ggit_rebase_operation_get_exec (GgitRebaseOperation
*rebase_operation);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRebaseOperation, ggit_rebase_operation_unref)
+
+G_END_DECLS
+
+#endif /* __GGIT_REBASE_OPERATION_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index da5010a..b2a43e8 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -180,6 +180,13 @@ typedef struct _GgitOId GgitOId;
typedef struct _GgitPatch GgitPatch;
/**
+ * GgitRebaseOperation:
+ *
+ * Represents a rebase operation.
+ */
+typedef struct _GgitRebaseOperation GgitRebaseOperation;
+
+/**
* GgitRebaseOptions:
*
* Represents the options used when rebasing.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]