summaryrefslogtreecommitdiff
path: root/include/git2/merge.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2/merge.h')
-rw-r--r--include/git2/merge.h76
1 files changed, 68 insertions, 8 deletions
diff --git a/include/git2/merge.h b/include/git2/merge.h
index cef6f775b..3354fbeab 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -7,11 +7,11 @@
#ifndef INCLUDE_git_merge_h__
#define INCLUDE_git_merge_h__
-#include "git2/common.h"
-#include "git2/types.h"
-#include "git2/oid.h"
-#include "git2/checkout.h"
-#include "git2/index.h"
+#include "common.h"
+#include "types.h"
+#include "oid.h"
+#include "checkout.h"
+#include "index.h"
/**
* @file git2/merge.h
@@ -66,6 +66,29 @@ typedef struct {
/**
+ * Option flags for `git_merge`.
+ *
+ * GIT_MERGE_NO_FASTFORWARD - Do not fast-forward.
+ */
+typedef enum {
+ GIT_MERGE_NO_FASTFORWARD = 1,
+ GIT_MERGE_FASTFORWARD_ONLY = 2,
+} git_merge_flags_t;
+
+typedef struct {
+ unsigned int version;
+
+ git_merge_flags_t merge_flags;
+ git_merge_tree_opts merge_tree_opts;
+
+ git_checkout_opts checkout_opts;
+} git_merge_opts;
+
+#define GIT_MERGE_OPTS_VERSION 1
+#define GIT_MERGE_OPTS_INIT {GIT_MERGE_OPTS_VERSION, 0, GIT_MERGE_TREE_OPTS_INIT, GIT_CHECKOUT_OPTS_INIT}
+
+
+/**
* Find a merge base between two commits
*
* @param out the OID of a merge base between 'one' and 'two'
@@ -85,15 +108,15 @@ GIT_EXTERN(int) git_merge_base(
*
* @param out the OID of a merge base considering all the commits
* @param repo the repository where the commits exist
- * @param input_array oids of the commits
* @param length The number of commits in the provided `input_array`
+ * @param input_array oids of the commits
* @return Zero on success; GIT_ENOTFOUND or -1 on failure.
*/
GIT_EXTERN(int) git_merge_base_many(
git_oid *out,
git_repository *repo,
- const git_oid input_array[],
- size_t length);
+ size_t length,
+ const git_oid input_array[]);
/**
* Creates a `git_merge_head` from the given reference
@@ -168,6 +191,43 @@ GIT_EXTERN(int) git_merge_trees(
const git_tree *their_tree,
const git_merge_tree_opts *opts);
+/**
+ * Merges the given commits into HEAD, producing a new commit.
+ *
+ * @param out the results of the merge
+ * @param repo the repository to merge
+ * @param merge_heads the heads to merge into
+ * @param merge_heads_len the number of heads to merge
+ * @param flags merge flags
+ */
+GIT_EXTERN(int) git_merge(
+ git_merge_result **out,
+ git_repository *repo,
+ const git_merge_head **their_heads,
+ size_t their_heads_len,
+ const git_merge_opts *opts);
+
+/**
+ * Returns true if a merge is up-to-date (we were asked to merge the target
+ * into itself.)
+ */
+GIT_EXTERN(int) git_merge_result_is_uptodate(git_merge_result *merge_result);
+
+/**
+ * Returns true if a merge is eligible for fastforward
+ */
+GIT_EXTERN(int) git_merge_result_is_fastforward(git_merge_result *merge_result);
+
+/**
+ * Gets the fast-forward OID if the merge was a fastforward.
+ *
+ * @param out the OID of the fast-forward
+ * @param merge_result the results of the merge
+ */
+GIT_EXTERN(int) git_merge_result_fastforward_oid(git_oid *out, git_merge_result *merge_result);
+
+GIT_EXTERN(void) git_merge_result_free(git_merge_result *merge_result);
+
/** @} */
GIT_END_DECL
#endif