[libgit2-glib] Add ggit_repository_rebase_init/open
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Add ggit_repository_rebase_init/open
- Date: Sat, 29 Aug 2015 11:45:35 +0000 (UTC)
commit f1f371c785e1c7b0bbc6d2a749a4d1f4a67f0a4c
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Aug 29 12:58:04 2015 +0200
Add ggit_repository_rebase_init/open
libgit2-glib/ggit-repository.c | 85 ++++++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-repository.h | 12 ++++++
2 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index a4e0cbc..0e37039 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -41,6 +41,8 @@
#include "ggit-cherry-pick-options.h"
#include "ggit-merge-options.h"
#include "ggit-index-entry.h"
+#include "ggit-annotated-commit.h"
+#include "ggit-rebase-options.h"
typedef struct _GgitRepositoryPrivate
@@ -3798,5 +3800,88 @@ ggit_repository_merge_commits (GgitRepository *repository,
return _ggit_index_wrap (out);
}
+/**
+ * ggit_repository_rebase_init:
+ * @repository: a #GgitRepository.
+ * @branch: (allow-none): the terminal commit to rebase, or %NULL to rebase the
+ * current branch.
+ * @upstream: (allow-none): the commit to begin rebasing from, or %NULL to
+ * rebase all reachable commits.
+ * @onto: (allow-none): the branch to rebase onto, or %NULL to rebase onto
+ * the given upstream.
+ * @options: a #GgitRebaseOptions to specify how rebase is performed, or %NULL.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Initializes a rebase operation to rebase the changes in @branch
+ * relative to @upstream onto another branch. To begin the rebase
+ * process, call git_rebase_next(). When you have finished with this
+ * object, call g_object_unref().
+ *
+ * Returns: (transfer full): a newly allocated #GgitRebase.
+ */
+GgitRebase *
+ggit_repository_rebase_init (GgitRepository *repository,
+ GgitAnnotatedCommit *branch,
+ GgitAnnotatedCommit *upstream,
+ GgitAnnotatedCommit *onto,
+ GgitRebaseOptions *options,
+ GError **error)
+{
+ git_rebase *rebase;
+ gint ret;
+
+ g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ ret = git_rebase_init (&rebase,
+ _ggit_native_get (repository),
+ branch != NULL ? _ggit_annotated_commit_get_annotated_commit (branch) : NULL,
+ upstream != NULL ? _ggit_annotated_commit_get_annotated_commit (upstream) :
NULL,
+ onto != NULL ? _ggit_annotated_commit_get_annotated_commit (onto) : NULL,
+ options != NULL ? _ggit_rebase_options_get_rebase_options (options) : NULL);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return NULL;
+ }
+
+ return _ggit_rebase_wrap (rebase);
+}
+
+/**
+ * ggit_repository_rebase_open:
+ * @repository: a #GgitRepository.
+ * @options: a #GgitRebaseOptions to specify how rebase is performed, or %NULL.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Opens an existing rebase that was previously started by either an
+ * invocation of ggit_rebase_init() or by another client.
+ *
+ * Returns: (transfer full): a newly allocated #GgitRebase.
+ */
+GgitRebase *
+ggit_repository_rebase_open (GgitRepository *repository,
+ GgitRebaseOptions *options,
+ GError **error)
+{
+ git_rebase *rebase;
+ gint ret;
+
+ g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ ret = git_rebase_open (&rebase,
+ _ggit_native_get (repository),
+ options != NULL ? _ggit_rebase_options_get_rebase_options (options) : NULL);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return NULL;
+ }
+
+ return _ggit_rebase_wrap (rebase);
+}
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 610eca8..0254a45 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -40,6 +40,7 @@
#include <libgit2-glib/ggit-commit.h>
#include <libgit2-glib/ggit-tree-builder.h>
#include <libgit2-glib/ggit-remote.h>
+#include <libgit2-glib/ggit-rebase.h>
G_BEGIN_DECLS
@@ -480,6 +481,17 @@ GgitIndex *ggit_repository_merge_commits (GgitRepository
GgitMergeOptions *merge_options,
GError **error);
+GgitRebase *ggit_repository_rebase_init (GgitRepository *repository,
+ GgitAnnotatedCommit *branch,
+ GgitAnnotatedCommit *upstream,
+ GgitAnnotatedCommit *onto,
+ GgitRebaseOptions *options,
+ GError **error);
+
+GgitRebase *ggit_repository_rebase_open (GgitRepository *repository,
+ GgitRebaseOptions *options,
+ GError **error);
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GgitRepository, g_object_unref)
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]