[libgit2-glib] Bind GgitMergeTreeOptions



commit c5aad14ab0d03c44016d35c147bf2b944361e585
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun Jun 30 22:35:41 2013 +0200

    Bind GgitMergeTreeOptions

 libgit2-glib/Makefile.am               |    2 +
 libgit2-glib/ggit-merge-tree-options.c |  116 ++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-merge-tree-options.h |   52 ++++++++++++++
 libgit2-glib/ggit-types.h              |    7 ++
 4 files changed, 177 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index 9cd2224..b38bd4f 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -39,6 +39,7 @@ INST_H_FILES =                                \
        ggit-index-entry-resolve-undo.h \
        ggit-main.h                     \
        ggit-message.h                  \
+       ggit-merge-tree-options.h       \
        ggit-native.h                   \
        ggit-object.h                   \
        ggit-object-factory.h           \
@@ -90,6 +91,7 @@ C_FILES =                             \
        ggit-index-entry-resolve-undo.c \
        ggit-main.c                     \
        ggit-message.c                  \
+       ggit-merge-tree-options.c       \
        ggit-native.c                   \
        ggit-object.c                   \
        ggit-object-factory.c           \
diff --git a/libgit2-glib/ggit-merge-tree-options.c b/libgit2-glib/ggit-merge-tree-options.c
new file mode 100644
index 0000000..255b141
--- /dev/null
+++ b/libgit2-glib/ggit-merge-tree-options.c
@@ -0,0 +1,116 @@
+/*
+ * ggit-merge_tree-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-merge-tree-options.h"
+
+struct _GgitMergeTreeOptions
+{
+       git_merge_tree_opts merge_options;
+};
+
+G_DEFINE_BOXED_TYPE (GgitMergeTreeOptions, ggit_merge_tree_options,
+                     ggit_merge_tree_options_copy, ggit_merge_tree_options_free)
+
+const git_merge_tree_opts *
+_ggit_merge_tree_options_get_merge_tree_options (GgitMergeTreeOptions *merge_options)
+{
+       /* NULL is common for merge_tree_options as it specifies to use the default
+        * so handle a NULL merge_tree_options here instead of in every caller.
+        */
+       if (merge_options == NULL)
+       {
+               return NULL;
+       }
+
+       return (const git_merge_tree_opts *)&merge_options->merge_options;
+}
+
+/**
+ * ggit_merge_tree_options_copy:
+ * @merge_options: a #GgitMergeTreeOptions.
+ *
+ * Copies @merge_options into a newly allocated #GgitMergeTreeOptions.
+ *
+ * Returns: (transfer full): a newly allocated #GgitMergeTreeOptions.
+ */
+GgitMergeTreeOptions *
+ggit_merge_tree_options_copy (GgitMergeTreeOptions *merge_options)
+{
+       GgitMergeTreeOptions *new_merge_options;
+
+       g_return_val_if_fail (merge_options != NULL, NULL);
+
+       new_merge_options = g_slice_new (GgitMergeTreeOptions);
+
+       new_merge_options->merge_options = merge_options->merge_options;
+
+       return new_merge_options;
+}
+
+/**
+ * ggit_merge_tree_options_free:
+ * @merge_options: a #GgitMergeTreeOptions.
+ *
+ * Frees @merge_options.
+ */
+void
+ggit_merge_tree_options_free (GgitMergeTreeOptions *merge_options)
+{
+       g_return_if_fail (merge_options != NULL);
+
+       g_slice_free (GgitMergeTreeOptions, merge_options);
+}
+
+/* FIXME: MISSING git_diff_similarity_metric bind */
+
+/**
+ * ggit_merge_tree_options_new:
+ * @flags: flags to consider when merging.
+ * @rename_threshold: similarity to consider a file renamed (default 50).
+ * @target_limit: maximum similarity sources to examine
+ *                (overrides the `merge_tree.renameLimit` config) (default 200).
+ * @automerge_mode: mode for automerging.
+ *
+ * Creates a new #GgitMergeTreeOptions.
+ *
+ * Returns: a newly allocated #GgitMergeTreeOptions.
+ */
+GgitMergeTreeOptions *
+ggit_merge_tree_options_new (GgitMergeTreeFlags     flags,
+                             guint                  rename_threshold,
+                             guint                  target_limit,
+                             GgitMergeAutomergeMode automerge_mode)
+{
+       GgitMergeTreeOptions *merge_options;
+       git_merge_tree_opts gmerge_options = GIT_MERGE_TREE_OPTS_INIT;
+
+       merge_options = g_slice_new (GgitMergeTreeOptions);
+
+       gmerge_options.flags = flags;
+       gmerge_options.rename_threshold = rename_threshold;
+       gmerge_options.target_limit = target_limit;
+       gmerge_options.automerge_flags = automerge_mode;
+
+       merge_options->merge_options = gmerge_options;
+
+       return merge_options;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-merge-tree-options.h b/libgit2-glib/ggit-merge-tree-options.h
new file mode 100644
index 0000000..128131a
--- /dev/null
+++ b/libgit2-glib/ggit-merge-tree-options.h
@@ -0,0 +1,52 @@
+/*
+ * ggit-merge_tree-options.h
+ * 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/>.
+ */
+
+
+#ifndef __GGIT_MERGE_TREE_OPTIONS_H__
+#define __GGIT_MERGE_TREE_OPTIONS_H__
+
+#include <glib-object.h>
+#include <git2.h>
+
+#include "ggit-types.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_MERGE_TREE_OPTIONS       (ggit_merge_tree_options_get_type ())
+#define GGIT_MERGE_TREE_OPTIONS(obj)       ((GgitMergeTreeOptions *)obj)
+
+GType                  ggit_merge_tree_options_get_type                (void) G_GNUC_CONST;
+
+const git_merge_tree_opts *
+                      _ggit_merge_tree_options_get_merge_tree_options  (GgitMergeTreeOptions   
*merge_options);
+
+GgitMergeTreeOptions  *ggit_merge_tree_options_copy                    (GgitMergeTreeOptions   
*merge_options);
+void                   ggit_merge_tree_options_free                    (GgitMergeTreeOptions   
*merge_options);
+
+GgitMergeTreeOptions  *ggit_merge_tree_options_new                     (GgitMergeTreeFlags      flags,
+                                                                        guint                   
rename_threshold,
+                                                                        guint                   target_limit,
+                                                                        GgitMergeAutomergeMode  
automerge_mode);
+
+G_END_DECLS
+
+#endif /* __GGIT_MERGE_TREE_OPTIONS_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 29d69eb..e7c4183 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -173,6 +173,13 @@ typedef struct _GgitIndexEntriesResolveUndo GgitIndexEntriesResolveUndo;
 typedef struct _GgitIndexEntryResolveUndo GgitIndexEntryResolveUndo;
 
 /**
+ * GgitMergeTreeOptions:
+ *
+ * Represents the options used when merging.
+ */
+typedef struct _GgitMergeTreeOptions GgitMergeTreeOptions;
+
+/**
  * GgitNative:
  *
  * Represents a generic native object.


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