[libgit2-glib/wip/adwait/commit_with_signature: 1/2] Added git_commit_create_with_signature




commit 276ac8af30bcd5e2c675a4ddc68424a3b3eef7fb
Author: Adwait Rawat <adwait rawat gmail com>
Date:   Tue Aug 13 16:56:39 2019 +0900

    Added git_commit_create_with_signature

 libgit2-glib/ggit-repository.c | 44 ++++++++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |  7 +++++++
 2 files changed, 51 insertions(+)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index f0c151d..cd3740f 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -3266,6 +3266,50 @@ ggit_repository_create_commit_from_ids (GgitRepository  *repository,
        return _ggit_oid_wrap (&id);
 }
 
+/**
+ * ggit_repository_create_commit_with_signature:
+ * @repository: a #GgitRepository.
+ * @commit_content: the content of the unsigned commit object.
+ * @signature: (allow-none): the signature to add to the commit.
+ * @signature_field: (allow-none): which header field should contain this
+ * signature. Leave `NULL` for the default of "gpgsig".
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Create a new commit using the (if not NULL) signature key and type of key provided.
+ *
+ * Returns: (transfer full) (nullable): the #GgitOId of the created commit object,
+ * or %NULL in case of an error.
+ *
+ */
+GgitOId *
+ggit_repository_create_commit_with_signature (GgitRepository  *repository,
+                                              const gchar     *commit_content,
+                                              const gchar     *signature,
+                                              const gchar     *signature_field,
+                                              GError         **error)
+{
+       gint ret;
+       git_oid oid;
+
+       g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+       g_return_val_if_fail (commit_content != NULL, NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+       ret = git_commit_create_with_signature (&oid,
+                                               _ggit_native_get (repository),
+                                               commit_content,
+                                               signature,
+                                               signature_field);
+
+       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 361afba..20dc064 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -161,6 +161,13 @@ GgitOId            *ggit_repository_create_commit_from_ids (
                                                        gint                   parent_count,
                                                        GError               **error);
 
+GgitOId            *ggit_repository_create_commit_with_signature (
+                                                       GgitRepository  *repository,
+                                                       const gchar     *commit_content,
+                                                       const gchar     *signature,
+                                                       const gchar     *signature_field,
+                                                       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]