[libgit2-glib] Added ggit_repository_create_commit_from_oids
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Added ggit_repository_create_commit_from_oids
- Date: Fri, 5 Jul 2013 10:37:59 +0000 (UTC)
commit 86700e0602a490b3873676cfae5d4578788ca0be
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Fri Jul 5 12:37:34 2013 +0200
Added ggit_repository_create_commit_from_oids
libgit2-glib/ggit-repository.c | 71 ++++++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-repository.h | 12 +++++++
2 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 000776a..668baa5 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -20,6 +20,7 @@
#include <gio/gio.h>
#include <git2.h>
+#include <git2/sys/commit.h>
#include "ggit-error.h"
#include "ggit-oid.h"
@@ -2103,6 +2104,76 @@ ggit_repository_create_commit (GgitRepository *repository,
}
/**
+ * ggit_repository_create_commit_from_oids:
+ * @repository: a #GgitRepository.
+ * @update_ref: (allow-none): name of the reference to update.
+ * @author: author signature.
+ * @committer: committer signature (and time of commit).
+ * @message_encoding: (allow-none): message encoding.
+ * @message: commit message.
+ * @tree: the tree of objects to commit.
+ * @parents: (array length=parent_count): parent commits.
+ * @parent_count: number of parent commits in @parents.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Create a new commit. If @update_ref is not %NULL, the given reference will
+ * be updated to point to the newly created commit. Use "HEAD" to update the
+ * HEAD of the current branch and make it point to this commit.
+ *
+ * If @message_encoding is set to %NULL, "UTF-8" encoding is assumed for the
+ * provided @message. Note that @message will not be cleaned up automatically.
+ * You can use #ggit_message_prettify to do this yourself if needed.
+ *
+ * Returns: the #GgitOId of the created commit object, or %NULL in case of an error.
+ *
+ */
+GgitOId *
+ggit_repository_create_commit_from_oids (GgitRepository *repository,
+ const gchar *update_ref,
+ GgitSignature *author,
+ GgitSignature *committer,
+ const gchar *message_encoding,
+ const gchar *message,
+ GgitOId *tree,
+ GgitOId **parents,
+ gint parent_count,
+ GError **error)
+{
+ gint ret;
+ git_oid oid;
+ git_oid **parents_native;
+ gint i;
+
+ parents_native = g_new0 (git_oid *, parent_count);
+
+ for (i = 0; i < parent_count; ++i)
+ {
+ parents_native[i] = (git_oid *)_ggit_oid_get_oid (parents[i]);
+ }
+
+ ret = git_commit_create_from_oids (&oid,
+ _ggit_native_get (repository),
+ update_ref,
+ _ggit_native_get (author),
+ _ggit_native_get (committer),
+ message_encoding,
+ message,
+ _ggit_oid_get_oid (tree),
+ parent_count,
+ (git_oid const **)parents_native);
+
+ g_free (parents_native);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return NULL;
+ }
+
+ return _ggit_oid_wrap (&oid);
+}
+
+/**
* ggit_repository_create_tree_builder:
* @repository: a #GgitRepository.
*
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 8e5df44..ac18618 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -136,6 +136,18 @@ GgitOId *ggit_repository_create_commit (GgitRepository *re
gint parent_count,
GError **error);
+GgitOId *ggit_repository_create_commit_from_oids (
+ GgitRepository *repository,
+ const gchar *update_ref,
+ GgitSignature *author,
+ GgitSignature *committer,
+ const gchar *message_encoding,
+ const gchar *message,
+ GgitOId *tree,
+ GgitOId **parents,
+ gint parent_count,
+ GError **error);
+
GgitOId *ggit_repository_create_tag (GgitRepository *repository,
const gchar *tag_name,
GgitObject *target,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]