[libgit2-glib] Bind GgitAnnotatedCommit
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind GgitAnnotatedCommit
- Date: Sat, 15 Aug 2015 11:28:31 +0000 (UTC)
commit 0786e18573fb6112339fad3eb74ea2c048eb2d67
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Aug 15 13:28:00 2015 +0200
Bind GgitAnnotatedCommit
libgit2-glib/Makefile.am | 4 +-
libgit2-glib/ggit-annotated-commit.c | 112 ++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-annotated-commit.h | 52 ++++++++++++++++
libgit2-glib/ggit-types.h | 7 ++
libgit2-glib/ggit.h.in | 1 +
5 files changed, 175 insertions(+), 1 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index d569b90..d063d5c 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -17,6 +17,7 @@ libgit2_glib_1_0_la_LDFLAGS = \
libgit2_glib_1_0_la_LIBADD = $(LIBGIT2_GLIB_LIBS)
H_FILES = \
+ ggit-annotated-commit.h \
ggit-blame.h \
ggit-blame-options.h \
ggit-blob.h \
@@ -60,7 +61,6 @@ H_FILES = \
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 \
@@ -85,6 +85,7 @@ BUILT_H_FILES = ggit.h
BUILT_H_FILES_ENUMS = ggit-enum-types.h
C_FILES = \
+ ggit-annotated-commit.c \
ggit-blame.c \
ggit-blame-options.c \
ggit-blob.c \
@@ -128,6 +129,7 @@ C_FILES = \
ggit-oid.c \
ggit-patch.c \
ggit-push-options.c \
+ ggit-rebase-options.c \
ggit-ref.c \
ggit-ref-spec.c \
ggit-reflog.c \
diff --git a/libgit2-glib/ggit-annotated-commit.c b/libgit2-glib/ggit-annotated-commit.c
new file mode 100644
index 0000000..e7d702c
--- /dev/null
+++ b/libgit2-glib/ggit-annotated-commit.c
@@ -0,0 +1,112 @@
+/*
+ * ggit-annotated-commit.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-annotated-commit.h"
+#include "ggit-oid.h"
+
+struct _GgitAnnotatedCommit
+{
+ gint ref_count;
+
+ git_annotated_commit *annotated_commit;
+};
+
+G_DEFINE_BOXED_TYPE (GgitAnnotatedCommit, ggit_annotated_commit,
+ ggit_annotated_commit_ref, ggit_annotated_commit_unref)
+
+GgitAnnotatedCommit *
+_ggit_annotated_commit_wrap (git_annotated_commit *annotated_commit)
+{
+ GgitAnnotatedCommit *glib_annotated_commit;
+
+ glib_annotated_commit = g_slice_new (GgitAnnotatedCommit);
+ glib_annotated_commit->ref_count = 1;
+ glib_annotated_commit->annotated_commit = annotated_commit;
+
+ return glib_annotated_commit;
+}
+
+git_annotated_commit *
+_ggit_annotated_commit_get_annotated_commit (GgitAnnotatedCommit *annotated_commit)
+{
+ return annotated_commit->annotated_commit;
+}
+
+/**
+ * ggit_annotated_commit_ref:
+ * @annotated_commit: a #GgitAnnotatedCommit.
+ *
+ * Atomically increments the reference count of @annotated_commit by one.
+ * This function is MT-safe and may be called from any thread.
+ *
+ * Returns: (transfer none): a newly allocated #GgitAnnotatedCommit.
+ */
+GgitAnnotatedCommit *
+ggit_annotated_commit_ref (GgitAnnotatedCommit *annotated_commit)
+{
+ g_return_val_if_fail (annotated_commit != NULL, NULL);
+
+ g_atomic_int_inc (&annotated_commit->ref_count);
+
+ return annotated_commit;
+}
+
+/**
+ * ggit_annotated_commit_unref:
+ * @annotated_commit: a #GgitAnnotatedCommit.
+ *
+ * Atomically decrements the reference count of @entry by one.
+ * If the reference count drops to 0, @entry is freed.
+ */
+void
+ggit_annotated_commit_unref (GgitAnnotatedCommit *annotated_commit)
+{
+ g_return_if_fail (annotated_commit != NULL);
+
+ if (g_atomic_int_dec_and_test (&annotated_commit->ref_count))
+ {
+ git_annotated_commit_free (annotated_commit->annotated_commit);
+ g_slice_free (GgitAnnotatedCommit, annotated_commit);
+ }
+}
+
+/**
+ * ggit_annotated_commit_get_id:
+ * @annotated_commit: a #GgitAnnotatedCommit.
+ *
+ * Gets the commit ID that the given @annotated_commit refs to.
+ *
+ * Returns: (transfer full): the commit ID that the given @annotated_commit refs to.
+ */
+GgitOId *
+ggit_annotated_commit_get_id (GgitAnnotatedCommit *annotated_commit)
+{
+ const git_oid *oid;
+
+ g_return_val_if_fail (annotated_commit != NULL, NULL);
+
+ oid = git_annotated_commit_id (annotated_commit->annotated_commit);
+
+ return _ggit_oid_wrap ((git_oid *)oid);
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-annotated-commit.h b/libgit2-glib/ggit-annotated-commit.h
new file mode 100644
index 0000000..ecceced
--- /dev/null
+++ b/libgit2-glib/ggit-annotated-commit.h
@@ -0,0 +1,52 @@
+/*
+ * ggit-annotated-commit.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_ANNOTATED_COMMIT_H__
+#define __GGIT_ANNOTATED_COMMIT_H__
+
+#include <glib-object.h>
+#include <git2.h>
+
+#include "ggit-types.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_ANNOTATED_COMMIT (ggit_annotated_commit_get_type ())
+#define GGIT_ANNOTATED_COMMIT(obj) ((GgitAnnotatedCommit *)obj)
+
+GType ggit_annotated_commit_get_type (void) G_GNUC_CONST;
+
+GgitAnnotatedCommit *_ggit_annotated_commit_wrap (git_annotated_commit
*annotated_commit);
+
+git_annotated_commit *_ggit_annotated_commit_get_annotated_commit (GgitAnnotatedCommit
*annotated_commit);
+
+GgitAnnotatedCommit *ggit_annotated_commit_ref (GgitAnnotatedCommit
*annotated_commit);
+void ggit_annotated_commit_unref (GgitAnnotatedCommit
*annotated_commit);
+
+GgitOId *ggit_annotated_commit_get_id (GgitAnnotatedCommit
*annotated_commit);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitAnnotatedCommit, ggit_annotated_commit_unref)
+
+G_END_DECLS
+
+#endif /* __GGIT_ANNOTATED_COMMIT_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index fc8959b..da5010a 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -26,6 +26,13 @@
G_BEGIN_DECLS
/**
+ * GgitAnnotatedCommit:
+ *
+ * Represents an annotated commit object.
+ */
+typedef struct _GgitAnnotatedCommit GgitAnnotatedCommit;
+
+/**
* GgitBranchEnumerator:
*
* Represents a branch enumerator.
diff --git a/libgit2-glib/ggit.h.in b/libgit2-glib/ggit.h.in
index cb82a84..606f90c 100644
--- a/libgit2-glib/ggit.h.in
+++ b/libgit2-glib/ggit.h.in
@@ -21,6 +21,7 @@
#ifndef __GGIT_H__
#define __GGIT_H__
+#include <libgit2-glib/ggit-annotated-commit.h>
#include <libgit2-glib/ggit-blob.h>
#include <libgit2-glib/ggit-blob-output-stream.h>
#include <libgit2-glib/ggit-branch-enumerator.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]