[libgit2-glib] Added ggit_repository_reset()



commit 6ba2afe8f036886cd81ba52a13a7b5237854a8f2
Author: Garrett Regier <garrettregier gmail com>
Date:   Fri Jun 8 00:43:54 2012 -0700

    Added ggit_repository_reset()

 libgit2-glib/ggit-repository.c |   33 +++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |    5 +++++
 libgit2-glib/ggit-types.h      |   13 +++++++++++++
 3 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index ddeeeed..7a6182a 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -26,6 +26,7 @@
 #include <git2/tag.h>
 #include <git2/branch.h>
 #include <git2/remote.h>
+#include <git2/reset.h>
 #include <git2/submodule.h>
 
 #include "ggit-error.h"
@@ -1558,4 +1559,36 @@ ggit_repository_submodule_foreach (GgitRepository        *repository,
 	return TRUE;
 }
 
+/**
+ * ggit_respository_reset:
+ * @repository: a #GgitRepository.
+ * @target: the target #GgitObject which is a commit or a tag.
+ * @reset_type: the #GgitResetType to perform.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Performs a reset of type @reset_type on @repository to @target,
+ * or @error will be set.
+ */
+void
+ggit_repository_reset (GgitRepository  *repository,
+                       GgitObject      *target,
+                       GgitResetType    reset_type,
+                       GError         **error)
+{
+	gint ret;
+
+	g_return_if_fail (GGIT_IS_REPOSITORY (repository));
+	g_return_if_fail (GGIT_IS_OBJECT (target));
+	g_return_if_fail (error == NULL || *error == NULL);
+
+	ret = git_reset (_ggit_native_get (repository),
+	                 _ggit_native_get (target),
+	                 reset_type);
+
+	if (ret != GIT_OK)
+	{
+		_ggit_error_set (error, ret);
+	}
+}
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 0c6bb5a..3daf4e9 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -202,6 +202,11 @@ gboolean            ggit_repository_submodule_foreach  (GgitRepository
                                                         gpointer                 user_data,
                                                         GError                 **error);
 
+void                ggit_repository_reset              (GgitRepository          *repository,
+                                                        GgitObject              *target,
+                                                        GgitResetType            reset_type,
+                                                        GError                 **error);
+
 G_END_DECLS
 
 #endif /* __GGIT_REPOSITORY_H__ */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 2ff97cb..947c500 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -354,6 +354,19 @@ typedef enum {
 } GgitRefType;
 
 /**
+ * GgitResetType:
+ * @GGIT_RESET_SOFT: The head will be moved to the commit.
+ * @GGIT_RESET_MIXED: the head will be moved to the commit and the index
+ *                    will be replaced with the content of the commit tree.
+ *
+ * Describes the type of reset to perform.
+ */
+typedef enum {
+	GGIT_RESET_SOFT  = 1,
+	GGIT_RESET_MIXED = 2
+} GgitResetType;
+
+/**
  * GgitSortMode:
  * @GGIT_SORT_NONE: Sorts the repository contents in no particular ordering;
  *                  this sorting is arbitrary, implementation-specific



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