summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-10-03 19:02:29 -0400
committerEdward Thomson <ethomson@microsoft.com>2014-10-26 22:59:48 -0400
commit18b00406c6427eb8c9d96864448474e1d85017de (patch)
treeee02fd12ee4b8f84e5ed53ca59ac771734bba16e /include/git2
parent796b03bd4969f170d8e7a7c9edd567f636b58cb3 (diff)
downloadlibgit2-18b00406c6427eb8c9d96864448474e1d85017de.tar.gz
s/git_merge_head/git_annotated_commit
Rename git_merge_head to git_annotated_commit, as it becomes used in more operations than just merge.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/annotated_commit.h99
-rw-r--r--include/git2/merge.h68
-rw-r--r--include/git2/rebase.h7
-rw-r--r--include/git2/types.h4
4 files changed, 108 insertions, 70 deletions
diff --git a/include/git2/annotated_commit.h b/include/git2/annotated_commit.h
new file mode 100644
index 000000000..87e3398a0
--- /dev/null
+++ b/include/git2/annotated_commit.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_annotated_commit_h__
+#define INCLUDE_git_annotated_commit_h__
+
+#include "common.h"
+#include "repository.h"
+#include "types.h"
+
+/**
+ * @file git2/annotated_commit.h
+ * @brief Git annotated commit routines
+ * @defgroup git_annotated_commit Git annotated commit routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Creates a `git_annotated_commit` from the given reference.
+ * The resulting git_annotated_commit must be freed with
+ * `git_annotated_commit_free`.
+ *
+ * @param out pointer to store the git_annotated_commit result in
+ * @param repo repository that contains the given reference
+ * @param ref reference to use to lookup the git_annotated_commit
+ * @return 0 on success or error code
+ */
+GIT_EXTERN(int) git_annotated_commit_from_ref(
+ git_annotated_commit **out,
+ git_repository *repo,
+ const git_reference *ref);
+
+/**
+ * Creates a `git_annotated_commit` from the given fetch head data.
+ * The resulting git_annotated_commit must be freed with
+ * `git_annotated_commit_free`.
+ *
+ * @param out pointer to store the git_annotated_commit result in
+ * @param repo repository that contains the given commit
+ * @param branch_name name of the (remote) branch
+ * @param remote_url url of the remote
+ * @param oid the commit object id of the remote branch
+ * @return 0 on success or error code
+ */
+GIT_EXTERN(int) git_annotated_commit_from_fetchhead(
+ git_annotated_commit **out,
+ git_repository *repo,
+ const char *branch_name,
+ const char *remote_url,
+ const git_oid *id);
+
+/**
+ * Creates a `git_annotated_commit` from the given commit id.
+ * The resulting git_annotated_commit must be freed with
+ * `git_annotated_commit_free`.
+ *
+ * An annotated commit contains information about how it was
+ * looked up, which may be useful for functions like merge or
+ * rebase to provide context to the operation. For example,
+ * conflict files will include the name of the source or target
+ * branches being merged. It is therefore preferable to use the
+ * most specific function (eg `git_annotated_commit_from_ref`)
+ * instead of this one when that data is known.
+ *
+ * @param out pointer to store the git_annotated_commit result in
+ * @param repo repository that contains the given commit
+ * @param id the commit object id to lookup
+ * @return 0 on success or error code
+ */
+GIT_EXTERN(int) git_annotated_commit_lookup(
+ git_annotated_commit **out,
+ git_repository *repo,
+ const git_oid *id);
+
+/**
+ * Gets the commit ID that the given `git_annotated_commit` refers to.
+ *
+ * @param head the given annotated commit
+ * @return commit id
+ */
+GIT_EXTERN(const git_oid *) git_annotated_commit_id(
+ const git_annotated_commit *commit);
+
+/**
+ * Frees a `git_annotated_commit`.
+ *
+ * @param annotated_commit annotated commit to free
+ */
+GIT_EXTERN(void) git_annotated_commit_free(
+ git_annotated_commit *commit);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/merge.h b/include/git2/merge.h
index ed1b9a30f..9082fd6fb 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -13,6 +13,7 @@
#include "oidarray.h"
#include "checkout.h"
#include "index.h"
+#include "annotated_commit.h"
/**
* @file git2/merge.h
@@ -303,7 +304,7 @@ GIT_EXTERN(int) git_merge_analysis(
git_merge_analysis_t *analysis_out,
git_merge_preference_t *preference_out,
git_repository *repo,
- const git_merge_head **their_heads,
+ const git_annotated_commit **their_heads,
size_t their_heads_len);
/**
@@ -382,69 +383,6 @@ GIT_EXTERN(int) git_merge_base_octopus(
const git_oid input_array[]);
/**
- * Creates a `git_merge_head` from the given reference. The resulting
- * git_merge_head must be freed with `git_merge_head_free`.
- *
- * @param out pointer to store the git_merge_head result in
- * @param repo repository that contains the given reference
- * @param ref reference to use as a merge input
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_head_from_ref(
- git_merge_head **out,
- git_repository *repo,
- const git_reference *ref);
-
-/**
- * Creates a `git_merge_head` from the given fetch head data. The resulting
- * git_merge_head must be freed with `git_merge_head_free`.
- *
- * @param out pointer to store the git_merge_head result in
- * @param repo repository that contains the given commit
- * @param branch_name name of the (remote) branch
- * @param remote_url url of the remote
- * @param oid the commit object id to use as a merge input
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_head_from_fetchhead(
- git_merge_head **out,
- git_repository *repo,
- const char *branch_name,
- const char *remote_url,
- const git_oid *oid);
-
-/**
- * Creates a `git_merge_head` from the given commit id. The resulting
- * git_merge_head must be freed with `git_merge_head_free`.
- *
- * @param out pointer to store the git_merge_head result in
- * @param repo repository that contains the given commit
- * @param id the commit object id to use as a merge input
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_head_from_id(
- git_merge_head **out,
- git_repository *repo,
- const git_oid *id);
-
-/**
- * Gets the commit ID that the given `git_merge_head` refers to.
- *
- * @param head the given merge head
- * @return commit id
- */
-GIT_EXTERN(const git_oid *) git_merge_head_id(
- const git_merge_head *head);
-
-/**
- * Frees a `git_merge_head`.
- *
- * @param head merge head to free
- */
-GIT_EXTERN(void) git_merge_head_free(
- git_merge_head *head);
-
-/**
* Merge two files as they exist in the in-memory data structures, using
* the given common ancestor as the baseline, producing a
* `git_merge_file_result` that reflects the merge result. The
@@ -557,7 +495,7 @@ GIT_EXTERN(int) git_merge_commits(
*/
GIT_EXTERN(int) git_merge(
git_repository *repo,
- const git_merge_head **their_heads,
+ const git_annotated_commit **their_heads,
size_t their_heads_len,
const git_merge_options *merge_opts,
const git_checkout_options *checkout_opts);
diff --git a/include/git2/rebase.h b/include/git2/rebase.h
index 46fadc67b..24d8fcf71 100644
--- a/include/git2/rebase.h
+++ b/include/git2/rebase.h
@@ -10,6 +10,7 @@
#include "common.h"
#include "types.h"
#include "oid.h"
+#include "annotated_commit.h"
/**
* @file git2/rebase.h
@@ -133,9 +134,9 @@ GIT_EXTERN(int) git_rebase_init_options(
GIT_EXTERN(int) git_rebase_init(
git_rebase **out,
git_repository *repo,
- const git_merge_head *branch,
- const git_merge_head *upstream,
- const git_merge_head *onto,
+ const git_annotated_commit *branch,
+ const git_annotated_commit *upstream,
+ const git_annotated_commit *onto,
const git_signature *signature,
const git_rebase_options *opts);
diff --git a/include/git2/types.h b/include/git2/types.h
index 416140716..aa7a56f56 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -174,8 +174,8 @@ typedef struct git_reference_iterator git_reference_iterator;
/** Transactional interface to references */
typedef struct git_transaction git_transaction;
-/** Merge heads, the input to merge */
-typedef struct git_merge_head git_merge_head;
+/** Annotated commits, the input to merge and rebase. */
+typedef struct git_annotated_commit git_annotated_commit;
/** Merge result */
typedef struct git_merge_result git_merge_result;