[libgit2-glib] Add submodule update



commit 378338ed989ac80a16062e4ee377bd5a36649c46
Author: Alberto Fanjul <albertofanjul gmail com>
Date:   Thu Jan 10 23:55:48 2019 +0100

    Add submodule update

 libgit2-glib/ggit-submodule.c | 37 +++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-submodule.h |  5 +++++
 2 files changed, 42 insertions(+)
---
diff --git a/libgit2-glib/ggit-submodule.c b/libgit2-glib/ggit-submodule.c
index cae1350..228d659 100644
--- a/libgit2-glib/ggit-submodule.c
+++ b/libgit2-glib/ggit-submodule.c
@@ -413,4 +413,41 @@ ggit_submodule_reload (GgitSubmodule  *submodule,
        }
 }
 
+/**
+ * ggit_submodule_update:
+ * @submodule: a #GgitSubmodule.
+ * @init: If the submodule is not initialized, setting this flag to true
+ *        will initialize the submodule before updating. Otherwise, this
+ *        will return an error if attempting to update an uninitialzed
+ *        repository. but setting this to true forces them to be updated.
+ * @options: a #GgitSubmoduleUpdateOptions object.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Update a submodule. This will clone a missing submodule and checkout
+ * the subrepository to the commit specified in the index of the containing
+ * repository. If the submodule repository doesn't contain the target commit
+ * (e.g. because fetchRecurseSubmodules isn't set), then the submodule is
+ * fetched using the fetch options supplied in options.
+ */
+void
+ggit_submodule_update (GgitSubmodule               *submodule,
+                       gboolean                     init,
+                       GgitSubmoduleUpdateOptions  *options,
+                       GError                     **error)
+{
+       gint ret;
+
+       g_return_if_fail (submodule != NULL);
+       g_return_if_fail (submodule->valid);
+       g_return_val_if_fail (options == NULL || GGIT_IS_SUBMODULE_UPDATE_OPTIONS (options), NULL);
+       g_return_if_fail (error == NULL || *error == NULL);
+
+       ret = git_submodule_update (submodule->submodule, init, options ? 
_ggit_submodule_update_options_get_submodule_update_options (options) : NULL);
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+       }
+}
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-submodule.h b/libgit2-glib/ggit-submodule.h
index c3cf9e5..9367d17 100644
--- a/libgit2-glib/ggit-submodule.h
+++ b/libgit2-glib/ggit-submodule.h
@@ -25,6 +25,7 @@
 #include <git2.h>
 
 #include "ggit-types.h"
+#include "ggit-submodule-update-options.h"
 
 G_BEGIN_DECLS
 
@@ -73,6 +74,10 @@ void                    ggit_submodule_reload                (GgitSubmodule
                                                               gboolean                     force,
                                                               GError                     **error);
 
+void                    ggit_submodule_update                (GgitSubmodule               *submodule,
+                                                              gboolean                     init,
+                                                              GgitSubmoduleUpdateOptions  *options,
+                                                              GError                     **error);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitSubmodule, ggit_submodule_unref)
 
 G_END_DECLS


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