Commit 18b00406 by Edward Thomson

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.
parent 796b03bd
......@@ -8,6 +8,7 @@
#ifndef INCLUDE_git_git_h__
#define INCLUDE_git_git_h__
#include "git2/annotated_commit.h"
#include "git2/attr.h"
#include "git2/blob.h"
#include "git2/blame.h"
......
/*
* 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
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
/*
* 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.
*/
#include "common.h"
#include "annotated_commit.h"
#include "git2/commit.h"
#include "git2/refs.h"
#include "git2/repository.h"
#include "git2/annotated_commit.h"
static int annotated_commit_init(
git_annotated_commit **out,
git_repository *repo,
const git_oid *id,
const char *ref_name,
const char *remote_url)
{
git_annotated_commit *annotated_commit;
int error = 0;
assert(out && id);
*out = NULL;
annotated_commit = git__calloc(1, sizeof(git_annotated_commit));
GITERR_CHECK_ALLOC(annotated_commit);
if (ref_name) {
annotated_commit->ref_name = git__strdup(ref_name);
GITERR_CHECK_ALLOC(annotated_commit->ref_name);
}
if (remote_url) {
annotated_commit->remote_url = git__strdup(remote_url);
GITERR_CHECK_ALLOC(annotated_commit->remote_url);
}
git_oid_fmt(annotated_commit->id_str, id);
annotated_commit->id_str[GIT_OID_HEXSZ] = '\0';
if ((error = git_commit_lookup(&annotated_commit->commit, repo, id)) < 0) {
git_annotated_commit_free(annotated_commit);
return error;
}
*out = annotated_commit;
return error;
}
int git_annotated_commit_from_ref(
git_annotated_commit **out,
git_repository *repo,
const git_reference *ref)
{
git_reference *resolved;
int error = 0;
assert(out && repo && ref);
*out = NULL;
if ((error = git_reference_resolve(&resolved, ref)) < 0)
return error;
error = annotated_commit_init(out, repo, git_reference_target(resolved),
git_reference_name(ref), NULL);
git_reference_free(resolved);
return error;
}
int git_annotated_commit_lookup(
git_annotated_commit **out,
git_repository *repo,
const git_oid *id)
{
assert(out && repo && id);
return annotated_commit_init(out, repo, id, NULL, NULL);
}
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)
{
assert(repo && id && branch_name && remote_url);
return annotated_commit_init(out, repo, id, branch_name, remote_url);
}
const git_oid *git_annotated_commit_id(
const git_annotated_commit *annotated_commit)
{
assert(annotated_commit);
return git_commit_id(annotated_commit->commit);
}
void git_annotated_commit_free(git_annotated_commit *annotated_commit)
{
if (annotated_commit == NULL)
return;
if (annotated_commit->commit != NULL)
git_commit_free(annotated_commit->commit);
if (annotated_commit->ref_name != NULL)
git__free(annotated_commit->ref_name);
if (annotated_commit->remote_url != NULL)
git__free(annotated_commit->remote_url);
git__free(annotated_commit);
}
/*
* 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_annotated_commit_h__
#define INCLUDE_annotated_commit_h__
#include "git2/oid.h"
/** Internal structure for merge inputs */
struct git_annotated_commit {
git_commit *commit;
char *ref_name;
char *remote_url;
char id_str[GIT_OID_HEXSZ+1];
};
#endif
......@@ -27,6 +27,7 @@
#include "filebuf.h"
#include "config.h"
#include "oidarray.h"
#include "annotated_commit.h"
#include "git2/types.h"
#include "git2/repository.h"
......@@ -40,6 +41,7 @@
#include "git2/config.h"
#include "git2/tree.h"
#include "git2/oidarray.h"
#include "git2/annotated_commit.h"
#include "git2/sys/index.h"
#include "git2/sys/hashsig.h"
......@@ -1837,7 +1839,7 @@ done:
static int write_merge_head(
git_repository *repo,
const git_merge_head *heads[],
const git_annotated_commit *heads[],
size_t heads_len)
{
git_filebuf file = GIT_FILEBUF_INIT;
......@@ -1852,7 +1854,7 @@ static int write_merge_head(
goto cleanup;
for (i = 0; i < heads_len; i++) {
if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->oid_str)) < 0)
if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->id_str)) < 0)
goto cleanup;
}
......@@ -1894,7 +1896,7 @@ cleanup:
}
struct merge_msg_entry {
const git_merge_head *merge_head;
const git_annotated_commit *merge_head;
bool written;
};
......@@ -2082,7 +2084,7 @@ static int merge_msg_write_remotes(
static int write_merge_msg(
git_repository *repo,
const git_merge_head *heads[],
const git_annotated_commit *heads[],
size_t heads_len)
{
git_filebuf file = GIT_FILEBUF_INIT;
......@@ -2128,7 +2130,7 @@ static int write_merge_msg(
if ((error = git_filebuf_printf(&file,
"%scommit '%s'", (i > 0) ? "; " : "",
entries[i].merge_head->oid_str)) < 0)
entries[i].merge_head->id_str)) < 0)
goto cleanup;
entries[i].written = 1;
......@@ -2176,7 +2178,7 @@ static int write_merge_msg(
continue;
if ((error = git_filebuf_printf(&file, "; commit '%s'",
entries[i].merge_head->oid_str)) < 0)
entries[i].merge_head->id_str)) < 0)
goto cleanup;
}
......@@ -2198,15 +2200,15 @@ cleanup:
int git_merge__setup(
git_repository *repo,
const git_merge_head *our_head,
const git_merge_head *heads[],
const git_annotated_commit *our_head,
const git_annotated_commit *heads[],
size_t heads_len)
{
int error = 0;
assert (repo && our_head && heads);
if ((error = git_repository__set_orig_head(repo, &our_head->oid)) == 0 &&
if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 &&
(error = write_merge_head(repo, heads, heads_len)) == 0 &&
(error = write_merge_mode(repo)) == 0) {
error = write_merge_msg(repo, heads, heads_len);
......@@ -2218,10 +2220,10 @@ int git_merge__setup(
/* Merge branches */
static int merge_ancestor_head(
git_merge_head **ancestor_head,
git_annotated_commit **ancestor_head,
git_repository *repo,
const git_merge_head *our_head,
const git_merge_head **their_heads,
const git_annotated_commit *our_head,
const git_annotated_commit **their_heads,
size_t their_heads_len)
{
git_oid *oids, ancestor_oid;
......@@ -2236,12 +2238,12 @@ static int merge_ancestor_head(
git_oid_cpy(&oids[0], git_commit_id(our_head->commit));
for (i = 0; i < their_heads_len; i++)
git_oid_cpy(&oids[i + 1], &their_heads[i]->oid);
git_oid_cpy(&oids[i + 1], git_annotated_commit_id(their_heads[i]));
if ((error = git_merge_base_many(&ancestor_oid, repo, their_heads_len + 1, oids)) < 0)
goto on_error;
error = git_merge_head_from_id(ancestor_head, repo, &ancestor_oid);
error = git_annotated_commit_lookup(ancestor_head, repo, &ancestor_oid);
on_error:
git__free(oids);
......@@ -2265,10 +2267,10 @@ static int merge_normalize_checkout_opts(
git_repository *repo,
git_checkout_options *checkout_opts,
const git_checkout_options *given_checkout_opts,
const git_merge_head *ancestor_head,
const git_merge_head *our_head,
const git_annotated_commit *ancestor_head,
const git_annotated_commit *our_head,
size_t their_heads_len,
const git_merge_head **their_heads)
const git_annotated_commit **their_heads)
{
int error = 0;
......@@ -2302,7 +2304,7 @@ static int merge_normalize_checkout_opts(
if (their_heads_len == 1 && their_heads[0]->ref_name)
checkout_opts->their_label = merge_their_label(their_heads[0]->ref_name);
else if (their_heads_len == 1)
checkout_opts->their_label = their_heads[0]->oid_str;
checkout_opts->their_label = their_heads[0]->id_str;
else
checkout_opts->their_label = "theirs";
}
......@@ -2516,13 +2518,13 @@ static int merge_state_cleanup(git_repository *repo)
}
static int merge_heads(
git_merge_head **ancestor_head_out,
git_merge_head **our_head_out,
git_annotated_commit **ancestor_head_out,
git_annotated_commit **our_head_out,
git_repository *repo,
const git_merge_head **their_heads,
const git_annotated_commit **their_heads,
size_t their_heads_len)
{
git_merge_head *ancestor_head = NULL, *our_head = NULL;
git_annotated_commit *ancestor_head = NULL, *our_head = NULL;
git_reference *our_ref = NULL;
int error = 0;
......@@ -2533,7 +2535,7 @@ static int merge_heads(
goto done;
if ((error = git_reference_lookup(&our_ref, repo, GIT_HEAD_FILE)) < 0 ||
(error = git_merge_head_from_ref(&our_head, repo, our_ref)) < 0)
(error = git_annotated_commit_from_ref(&our_head, repo, our_ref)) < 0)
goto done;
if ((error = merge_ancestor_head(&ancestor_head, repo, our_head, their_heads, their_heads_len)) < 0) {
......@@ -2549,8 +2551,8 @@ static int merge_heads(
done:
if (error < 0) {
git_merge_head_free(ancestor_head);
git_merge_head_free(our_head);
git_annotated_commit_free(ancestor_head);
git_annotated_commit_free(our_head);
}
git_reference_free(our_ref);
......@@ -2595,10 +2597,10 @@ 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)
{
git_merge_head *ancestor_head = NULL, *our_head = NULL;
git_annotated_commit *ancestor_head = NULL, *our_head = NULL;
int error = 0;
assert(analysis_out && preference_out && repo && their_heads);
......@@ -2623,11 +2625,13 @@ int git_merge_analysis(
goto done;
/* We're up-to-date if we're trying to merge our own common ancestor. */
if (ancestor_head && git_oid_equal(&ancestor_head->oid, &their_heads[0]->oid))
if (ancestor_head && git_oid_equal(
git_annotated_commit_id(ancestor_head), git_annotated_commit_id(their_heads[0])))
*analysis_out |= GIT_MERGE_ANALYSIS_UP_TO_DATE;
/* We're fastforwardable if we're our own common ancestor. */
else if (ancestor_head && git_oid_equal(&ancestor_head->oid, &our_head->oid))
else if (ancestor_head && git_oid_equal(
git_annotated_commit_id(ancestor_head), git_annotated_commit_id(our_head)))
*analysis_out |= GIT_MERGE_ANALYSIS_FASTFORWARD | GIT_MERGE_ANALYSIS_NORMAL;
/* Otherwise, just a normal merge is possible. */
......@@ -2635,21 +2639,21 @@ int git_merge_analysis(
*analysis_out |= GIT_MERGE_ANALYSIS_NORMAL;
done:
git_merge_head_free(ancestor_head);
git_merge_head_free(our_head);
git_annotated_commit_free(ancestor_head);
git_annotated_commit_free(our_head);
return error;
}
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 *given_checkout_opts)
{
git_reference *our_ref = NULL;
git_checkout_options checkout_opts;
git_merge_head *ancestor_head = NULL, *our_head = NULL;
git_annotated_commit *ancestor_head = NULL, *our_head = NULL;
git_tree *ancestor_tree = NULL, *our_tree = NULL, **their_trees = NULL;
git_index *index_new = NULL;
size_t i;
......@@ -2712,126 +2716,14 @@ done:
git__free(their_trees);
git_merge_head_free(our_head);
git_merge_head_free(ancestor_head);
git_annotated_commit_free(our_head);
git_annotated_commit_free(ancestor_head);
git_reference_free(our_ref);
return error;
}
/* Merge heads are the input to merge */
static int merge_head_init(
git_merge_head **out,
git_repository *repo,
const char *ref_name,
const char *remote_url,
const git_oid *oid)
{
git_merge_head *head;
int error = 0;
assert(out && oid);
*out = NULL;
head = git__calloc(1, sizeof(git_merge_head));
GITERR_CHECK_ALLOC(head);
if (ref_name) {
head->ref_name = git__strdup(ref_name);
GITERR_CHECK_ALLOC(head->ref_name);
}
if (remote_url) {
head->remote_url = git__strdup(remote_url);
GITERR_CHECK_ALLOC(head->remote_url);
}
git_oid_cpy(&head->oid, oid);
git_oid_fmt(head->oid_str, oid);
head->oid_str[GIT_OID_HEXSZ] = '\0';
if ((error = git_commit_lookup(&head->commit, repo, &head->oid)) < 0) {
git_merge_head_free(head);
return error;
}
*out = head;
return error;
}
int git_merge_head_from_ref(
git_merge_head **out,
git_repository *repo,
const git_reference *ref)
{
git_reference *resolved;
int error = 0;
assert(out && repo && ref);
*out = NULL;
if ((error = git_reference_resolve(&resolved, ref)) < 0)
return error;
error = merge_head_init(out, repo, git_reference_name(ref), NULL,
git_reference_target(resolved));
git_reference_free(resolved);
return error;
}
int git_merge_head_from_id(
git_merge_head **out,
git_repository *repo,
const git_oid *oid)
{
assert(out && repo && oid);
return merge_head_init(out, repo, NULL, NULL, oid);
}
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)
{
assert(repo && branch_name && remote_url && oid);
return merge_head_init(out, repo, branch_name, remote_url, oid);
}
const git_oid *git_merge_head_id(
const git_merge_head *head)
{
assert(head);
return &head->oid;
}
void git_merge_head_free(git_merge_head *head)
{
if (head == NULL)
return;
if (head->commit != NULL)
git_object_free((git_object *)head->commit);
if (head->ref_name != NULL)
git__free(head->ref_name);
if (head->remote_url != NULL)
git__free(head->remote_url);
git__free(head);
}
int git_merge_init_options(git_merge_options *opts, unsigned int version)
{
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
......
......@@ -110,16 +110,6 @@ typedef struct {
int binary:1;
} git_merge_diff;
/** Internal structure for merge inputs */
struct git_merge_head {
char *ref_name;
char *remote_url;
git_oid oid;
char oid_str[GIT_OID_HEXSZ+1];
git_commit *commit;
};
int git_merge__bases_many(
git_commit_list **out,
git_revwalk *walk,
......@@ -145,8 +135,8 @@ void git_merge_diff_list__free(git_merge_diff_list *diff_list);
int git_merge__setup(
git_repository *repo,
const git_merge_head *our_head,
const git_merge_head *heads[],
const git_annotated_commit *our_head,
const git_annotated_commit *heads[],
size_t heads_len);
int git_merge__check_result(git_repository *repo, git_index *index_new);
......
......@@ -13,8 +13,10 @@
#include "merge.h"
#include "array.h"
#include "config.h"
#include "annotated_commit.h"
#include <git2/types.h>
#include <git2/annotated_commit.h>
#include <git2/rebase.h>
#include <git2/commit.h>
#include <git2/reset.h>
......@@ -352,14 +354,14 @@ static int rebase_setupfile(git_rebase *rebase, const char *filename, int flags,
return error;
}
static const char *rebase_onto_name(const git_merge_head *onto)
static const char *rebase_onto_name(const git_annotated_commit *onto)
{
if (onto->ref_name && git__strncmp(onto->ref_name, "refs/heads/", 11) == 0)
return onto->ref_name + 11;
else if (onto->ref_name)
return onto->ref_name;
else
return onto->oid_str;
return onto->id_str;
}
static int rebase_setupfiles_merge(git_rebase *rebase)
......@@ -519,9 +521,9 @@ done:
static int rebase_init_operations(
git_rebase *rebase,
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)
{
git_revwalk *revwalk = NULL;
git_commit *commit;
......@@ -534,8 +536,8 @@ static int rebase_init_operations(
upstream = onto;
if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 ||
(error = git_revwalk_push(revwalk, &branch->oid)) < 0 ||
(error = git_revwalk_hide(revwalk, &upstream->oid)) < 0)
(error = git_revwalk_push(revwalk, git_annotated_commit_id(branch))) < 0 ||
(error = git_revwalk_hide(revwalk, git_annotated_commit_id(upstream))) < 0)
goto done;
git_revwalk_sorting(revwalk, GIT_SORT_REVERSE | GIT_SORT_TIME);
......@@ -565,9 +567,9 @@ done:
static int rebase_init_merge(
git_rebase *rebase,
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)
{
if (rebase_init_operations(rebase, repo, branch, upstream, onto) < 0)
return -1;
......@@ -581,9 +583,9 @@ static int rebase_init_merge(
static int rebase_init(
git_rebase *rebase,
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_rebase_options *opts)
{
git_buf state_path = GIT_BUF_INIT;
......@@ -597,8 +599,8 @@ static int rebase_init(
rebase->orig_head_name = git__strdup(branch->ref_name ? branch->ref_name : ORIG_DETACHED_HEAD);
rebase->quiet = opts->quiet;
git_oid_cpy(&rebase->orig_head_id, &branch->oid);
git_oid_cpy(&rebase->onto_id, &onto->oid);
git_oid_cpy(&rebase->orig_head_id, git_annotated_commit_id(branch));
git_oid_cpy(&rebase->onto_id, git_annotated_commit_id(onto));
if (!rebase->orig_head_name || !rebase->state_path)
return -1;
......@@ -613,9 +615,9 @@ static int rebase_init(
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 *given_opts)
{
......@@ -651,7 +653,7 @@ int git_rebase_init(
(error = git_buf_printf(&reflog,
"rebase: checkout %s", rebase_onto_name(onto))) < 0 ||
(error = git_reference_create(&head_ref, repo, GIT_HEAD_FILE,
&onto->oid, 1, signature, reflog.ptr)) < 0 ||
git_annotated_commit_id(onto), 1, signature, reflog.ptr)) < 0 ||
(error = git_checkout_head(repo, &checkout_opts)) < 0)
goto done;
......
......@@ -6,6 +6,7 @@
#include "merge.h"
#include "git2/merge.h"
#include "git2/sys/index.h"
#include "git2/annotated_commit.h"
int merge_trees_from_branches(
git_index **index, git_repository *repo,
......@@ -84,7 +85,7 @@ int merge_branches(git_repository *repo,
git_merge_options *merge_opts, git_checkout_options *checkout_opts)
{
git_reference *head_ref, *theirs_ref;
git_merge_head *theirs_head;
git_annotated_commit *theirs_head;
git_checkout_options head_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
head_checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
......@@ -93,13 +94,13 @@ int merge_branches(git_repository *repo,
cl_git_pass(git_checkout_head(repo, &head_checkout_opts));
cl_git_pass(git_reference_lookup(&theirs_ref, repo, theirs_branch));
cl_git_pass(git_merge_head_from_ref(&theirs_head, repo, theirs_ref));
cl_git_pass(git_annotated_commit_from_ref(&theirs_head, repo, theirs_ref));
cl_git_pass(git_merge(repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)&theirs_head, 1, merge_opts, checkout_opts));
git_reference_free(head_ref);
git_reference_free(theirs_ref);
git_merge_head_free(theirs_head);
git_annotated_commit_free(theirs_head);
return 0;
}
......
#include "clar_libgit2.h"
#include "git2/repository.h"
#include "git2/merge.h"
#include "git2/annotated_commit.h"
#include "git2/sys/index.h"
#include "merge.h"
#include "../merge_helpers.h"
......@@ -43,17 +44,17 @@ static void analysis_from_branch(
{
git_buf refname = GIT_BUF_INIT;
git_reference *their_ref;
git_merge_head *their_head;
git_annotated_commit *their_head;
git_buf_printf(&refname, "%s%s", GIT_REFS_HEADS_DIR, branchname);
cl_git_pass(git_reference_lookup(&their_ref, repo, git_buf_cstr(&refname)));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_merge_analysis(merge_analysis, merge_pref, repo, (const git_merge_head **)&their_head, 1));
cl_git_pass(git_merge_analysis(merge_analysis, merge_pref, repo, (const git_annotated_commit **)&their_head, 1));
git_buf_free(&refname);
git_merge_head_free(their_head);
git_annotated_commit_free(their_head);
git_reference_free(their_ref);
}
......
......@@ -89,18 +89,18 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
static int merge_branch(void)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
git_annotated_commit *their_head;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
int error;
cl_git_pass(git_oid_fromstr(&their_oids[0], MERGE_BRANCH_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
cl_git_pass(git_annotated_commit_lookup(&their_head, repo, &their_oids[0]));
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
error = git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
error = git_merge(repo, (const git_annotated_commit **)&their_head, 1, &merge_opts, &checkout_opts);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(their_head);
return error;
}
......
......@@ -76,15 +76,15 @@ void test_merge_workdir_setup__one_branch(void)
{
git_oid our_oid;
git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1];
git_annotated_commit *our_head, *their_heads[1];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -93,8 +93,8 @@ void test_merge_workdir_setup__one_branch(void)
git_reference_free(octo1_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
/* git merge --no-ff 16f825815cfd20a07a75c71554e82d8eede0b061 */
......@@ -102,23 +102,23 @@ void test_merge_workdir_setup__one_oid(void)
{
git_oid our_oid;
git_oid octo1_oid;
git_merge_head *our_head, *their_heads[1];
git_annotated_commit *our_head, *their_heads[1];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
/* git merge octo1 octo2 */
......@@ -127,18 +127,18 @@ void test_merge_workdir_setup__two_branches(void)
git_oid our_oid;
git_reference *octo1_ref;
git_reference *octo2_ref;
git_merge_head *our_head, *their_heads[2];
git_annotated_commit *our_head, *their_heads[2];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -148,9 +148,9 @@ void test_merge_workdir_setup__two_branches(void)
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
}
/* git merge octo1 octo2 octo3 */
......@@ -160,21 +160,21 @@ void test_merge_workdir_setup__three_branches(void)
git_reference *octo1_ref;
git_reference *octo2_ref;
git_reference *octo3_ref;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -185,10 +185,10 @@ void test_merge_workdir_setup__three_branches(void)
git_reference_free(octo2_ref);
git_reference_free(octo3_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
/* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 158dc7bedb202f5b26502bf3574faa7f4238d56c 50ce7d7d01217679e26c55939eef119e0c93e272 */
......@@ -198,31 +198,31 @@ void test_merge_workdir_setup__three_oids(void)
git_oid octo1_oid;
git_oid octo2_oid;
git_oid octo3_oid;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo3_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; commit '" OCTO2_OID "'; commit '" OCTO3_OID "'\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
/* git merge octo1 158dc7bedb202f5b26502bf3574faa7f4238d56c */
......@@ -231,18 +231,18 @@ void test_merge_workdir_setup__branches_and_oids_1(void)
git_oid our_oid;
git_reference *octo1_ref;
git_oid octo2_oid;
git_merge_head *our_head, *their_heads[2];
git_annotated_commit *our_head, *their_heads[2];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -251,9 +251,9 @@ void test_merge_workdir_setup__branches_and_oids_1(void)
git_reference_free(octo1_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
}
/* git merge octo1 158dc7bedb202f5b26502bf3574faa7f4238d56c octo3 54269b3f6ec3d7d4ede24dd350dd5d605495c3ae */
......@@ -264,24 +264,24 @@ void test_merge_workdir_setup__branches_and_oids_2(void)
git_oid octo2_oid;
git_reference *octo3_ref;
git_oid octo4_oid;
git_merge_head *our_head, *their_heads[4];
git_annotated_commit *our_head, *their_heads[4];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo2_oid));
cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_oid_fromstr(&octo4_oid, OCTO4_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[3], repo, &octo4_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[3], repo, &octo4_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -291,11 +291,11 @@ void test_merge_workdir_setup__branches_and_oids_2(void)
git_reference_free(octo1_ref);
git_reference_free(octo3_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_merge_head_free(their_heads[3]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
git_annotated_commit_free(their_heads[3]);
}
/* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 octo2 50ce7d7d01217679e26c55939eef119e0c93e272 octo4 */
......@@ -306,24 +306,24 @@ void test_merge_workdir_setup__branches_and_oids_3(void)
git_reference *octo2_ref;
git_oid octo3_oid;
git_reference *octo4_ref;
git_merge_head *our_head, *their_heads[4];
git_annotated_commit *our_head, *their_heads[4];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo3_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -333,11 +333,11 @@ void test_merge_workdir_setup__branches_and_oids_3(void)
git_reference_free(octo2_ref);
git_reference_free(octo4_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_merge_head_free(their_heads[3]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
git_annotated_commit_free(their_heads[3]);
}
/* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 octo2 50ce7d7d01217679e26c55939eef119e0c93e272 octo4 octo5 */
......@@ -349,27 +349,27 @@ void test_merge_workdir_setup__branches_and_oids_4(void)
git_oid octo3_oid;
git_reference *octo4_ref;
git_reference *octo5_ref;
git_merge_head *our_head, *their_heads[5];
git_annotated_commit *our_head, *their_heads[5];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_oid));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo3_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo3_oid));
cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_reference_lookup(&octo5_ref, repo, GIT_REFS_HEADS_DIR OCTO5_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[4], repo, octo5_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[4], repo, octo5_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 5));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 5));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n" OCTO5_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -380,12 +380,12 @@ void test_merge_workdir_setup__branches_and_oids_4(void)
git_reference_free(octo4_ref);
git_reference_free(octo5_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_merge_head_free(their_heads[3]);
git_merge_head_free(their_heads[4]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
git_annotated_commit_free(their_heads[3]);
git_annotated_commit_free(their_heads[4]);
}
/* git merge octo1 octo1 octo1 */
......@@ -395,21 +395,21 @@ void test_merge_workdir_setup__three_same_branches(void)
git_reference *octo1_1_ref;
git_reference *octo1_2_ref;
git_reference *octo1_3_ref;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_1_ref));
cl_git_pass(git_reference_lookup(&octo1_2_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo1_2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo1_2_ref));
cl_git_pass(git_reference_lookup(&octo1_3_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo1_3_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo1_3_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO1_OID "\n" OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -420,10 +420,10 @@ void test_merge_workdir_setup__three_same_branches(void)
git_reference_free(octo1_2_ref);
git_reference_free(octo1_3_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
/* git merge 16f825815cfd20a07a75c71554e82d8eede0b061 16f825815cfd20a07a75c71554e82d8eede0b061 16f825815cfd20a07a75c71554e82d8eede0b061 */
......@@ -433,31 +433,31 @@ void test_merge_workdir_setup__three_same_oids(void)
git_oid octo1_1_oid;
git_oid octo1_2_oid;
git_oid octo1_3_oid;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &octo1_1_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &octo1_1_oid));
cl_git_pass(git_oid_fromstr(&octo1_2_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[1], repo, &octo1_2_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[1], repo, &octo1_2_oid));
cl_git_pass(git_oid_fromstr(&octo1_3_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[2], repo, &octo1_3_oid));
cl_git_pass(git_annotated_commit_lookup(&their_heads[2], repo, &octo1_3_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO1_OID "\n" OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge commit '" OCTO1_OID "'; commit '" OCTO1_OID "'; commit '" OCTO1_OID "'\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
static int create_remote_tracking_branch(const char *branch_name, const char *oid_str)
......@@ -508,17 +508,17 @@ void test_merge_workdir_setup__remote_tracking_one_branch(void)
{
git_oid our_oid;
git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1];
git_annotated_commit *our_head, *their_heads[1];
cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -527,8 +527,8 @@ void test_merge_workdir_setup__remote_tracking_one_branch(void)
git_reference_free(octo1_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
/* git merge refs/remotes/origin/octo1 refs/remotes/origin/octo2 */
......@@ -537,21 +537,21 @@ void test_merge_workdir_setup__remote_tracking_two_branches(void)
git_oid our_oid;
git_reference *octo1_ref;
git_reference *octo2_ref;
git_merge_head *our_head, *their_heads[2];
git_annotated_commit *our_head, *their_heads[2];
cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -561,9 +561,9 @@ void test_merge_workdir_setup__remote_tracking_two_branches(void)
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
}
/* git merge refs/remotes/origin/octo1 refs/remotes/origin/octo2 refs/remotes/origin/octo3 */
......@@ -573,25 +573,25 @@ void test_merge_workdir_setup__remote_tracking_three_branches(void)
git_reference *octo1_ref;
git_reference *octo2_ref;
git_reference *octo3_ref;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
cl_git_pass(create_remote_tracking_branch(OCTO3_BRANCH, OCTO3_OID));
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO3_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -602,10 +602,10 @@ void test_merge_workdir_setup__remote_tracking_three_branches(void)
git_reference_free(octo2_ref);
git_reference_free(octo3_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
/* git merge octo1 refs/remotes/origin/octo2 */
......@@ -614,20 +614,20 @@ void test_merge_workdir_setup__normal_branch_and_remote_tracking_branch(void)
git_oid our_oid;
git_reference *octo1_ref;
git_reference *octo2_ref;
git_merge_head *our_head, *their_heads[2];
git_annotated_commit *our_head, *their_heads[2];
cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -637,9 +637,9 @@ void test_merge_workdir_setup__normal_branch_and_remote_tracking_branch(void)
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
}
/* git merge refs/remotes/origin/octo1 octo2 */
......@@ -648,20 +648,20 @@ void test_merge_workdir_setup__remote_tracking_branch_and_normal_branch(void)
git_oid our_oid;
git_reference *octo1_ref;
git_reference *octo2_ref;
git_merge_head *our_head, *their_heads[2];
git_annotated_commit *our_head, *their_heads[2];
cl_git_pass(create_remote_tracking_branch(OCTO1_BRANCH, OCTO1_OID));
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -671,9 +671,9 @@ void test_merge_workdir_setup__remote_tracking_branch_and_normal_branch(void)
git_reference_free(octo1_ref);
git_reference_free(octo2_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
}
/* git merge octo1 refs/remotes/origin/octo2 octo3 refs/remotes/origin/octo4 */
......@@ -684,27 +684,27 @@ void test_merge_workdir_setup__two_remote_tracking_branch_and_two_normal_branche
git_reference *octo2_ref;
git_reference *octo3_ref;
git_reference *octo4_ref;
git_merge_head *our_head, *their_heads[4];
git_annotated_commit *our_head, *their_heads[4];
cl_git_pass(create_remote_tracking_branch(OCTO2_BRANCH, OCTO2_OID));
cl_git_pass(create_remote_tracking_branch(OCTO4_BRANCH, OCTO4_OID));
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_reference_lookup(&octo2_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[1], repo, octo2_ref));
cl_git_pass(git_reference_lookup(&octo3_ref, repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[2], repo, octo3_ref));
cl_git_pass(git_reference_lookup(&octo4_ref, repo, GIT_REFS_REMOTES_DIR "origin/" OCTO4_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[3], repo, octo4_ref));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -716,11 +716,11 @@ void test_merge_workdir_setup__two_remote_tracking_branch_and_two_normal_branche
git_reference_free(octo3_ref);
git_reference_free(octo4_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_merge_head_free(their_heads[3]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
git_annotated_commit_free(their_heads[3]);
}
/* git pull origin branch octo1 */
......@@ -728,23 +728,23 @@ void test_merge_workdir_setup__pull_one(void)
{
git_oid our_oid;
git_oid octo1_1_oid;
git_merge_head *our_head, *their_heads[1];
git_annotated_commit *our_head, *their_heads[1];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_1_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_1_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 1));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 1));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch 'octo1' of http://remote.url/repo.git\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
/* git pull origin octo1 octo2 */
......@@ -753,27 +753,27 @@ void test_merge_workdir_setup__pull_two(void)
git_oid our_oid;
git_oid octo1_oid;
git_oid octo2_oid;
git_merge_head *our_head, *their_heads[2];
git_annotated_commit *our_head, *their_heads[2];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 2));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 2));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO2_BRANCH "' of http://remote.url/repo.git\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
}
/* git pull origin octo1 octo2 octo3 */
......@@ -783,31 +783,31 @@ void test_merge_workdir_setup__pull_three(void)
git_oid octo1_oid;
git_oid octo2_oid;
git_oid octo3_oid;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &octo1_oid));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.url/repo.git", &octo2_oid));
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.url/repo.git", &octo3_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.url/repo.git", &octo3_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "', '" OCTO2_BRANCH "' and '" OCTO3_BRANCH "' of http://remote.url/repo.git\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
void test_merge_workdir_setup__three_remotes(void)
......@@ -816,31 +816,31 @@ void test_merge_workdir_setup__three_remotes(void)
git_oid octo1_oid;
git_oid octo2_oid;
git_oid octo3_oid;
git_merge_head *our_head, *their_heads[3];
git_annotated_commit *our_head, *their_heads[3];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.third/repo.git", &octo3_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.third/repo.git", &octo3_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 3));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 3));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branch '" OCTO1_BRANCH "' of http://remote.first/repo.git, branch '" OCTO2_BRANCH "' of http://remote.second/repo.git, branch '" OCTO3_BRANCH "' of http://remote.third/repo.git\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
}
void test_merge_workdir_setup__two_remotes(void)
......@@ -850,35 +850,35 @@ void test_merge_workdir_setup__two_remotes(void)
git_oid octo2_oid;
git_oid octo3_oid;
git_oid octo4_oid;
git_merge_head *our_head, *their_heads[4];
git_annotated_commit *our_head, *their_heads[4];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_oid_fromstr(&octo1_oid, OCTO1_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.first/repo.git", &octo1_oid));
cl_git_pass(git_oid_fromstr(&octo2_oid, OCTO2_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[1], repo, GIT_REFS_HEADS_DIR OCTO2_BRANCH, "http://remote.second/repo.git", &octo2_oid));
cl_git_pass(git_oid_fromstr(&octo3_oid, OCTO3_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.first/repo.git", &octo3_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[2], repo, GIT_REFS_HEADS_DIR OCTO3_BRANCH, "http://remote.first/repo.git", &octo3_oid));
cl_git_pass(git_oid_fromstr(&octo4_oid, OCTO4_OID));
cl_git_pass(git_merge_head_from_fetchhead(&their_heads[3], repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH, "http://remote.second/repo.git", &octo4_oid));
cl_git_pass(git_annotated_commit_from_fetchhead(&their_heads[3], repo, GIT_REFS_HEADS_DIR OCTO4_BRANCH, "http://remote.second/repo.git", &octo4_oid));
cl_git_pass(git_merge__setup(repo, our_head, (const git_merge_head **)their_heads, 4));
cl_git_pass(git_merge__setup(repo, our_head, (const git_annotated_commit **)their_heads, 4));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n" OCTO2_OID "\n" OCTO3_OID "\n" OCTO4_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
cl_assert(test_file_contents(GIT_MERGE_MODE_FILE, "no-ff"));
cl_assert(test_file_contents(GIT_MERGE_MSG_FILE, "Merge branches '" OCTO1_BRANCH "' and '" OCTO3_BRANCH "' of http://remote.first/repo.git, branches '" OCTO2_BRANCH "' and '" OCTO4_BRANCH "' of http://remote.second/repo.git\n"));
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_merge_head_free(their_heads[1]);
git_merge_head_free(their_heads[2]);
git_merge_head_free(their_heads[3]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
git_annotated_commit_free(their_heads[1]);
git_annotated_commit_free(their_heads[2]);
git_annotated_commit_free(their_heads[3]);
}
void test_merge_workdir_setup__id_from_head(void)
......@@ -886,39 +886,39 @@ void test_merge_workdir_setup__id_from_head(void)
git_oid expected_id;
const git_oid *id;
git_reference *ref;
git_merge_head *heads[3];
git_annotated_commit *heads[3];
cl_git_pass(git_oid_fromstr(&expected_id, OCTO1_OID));
cl_git_pass(git_merge_head_from_fetchhead(&heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &expected_id));
id = git_merge_head_id(heads[0]);
cl_git_pass(git_annotated_commit_from_fetchhead(&heads[0], repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH, "http://remote.url/repo.git", &expected_id));
id = git_annotated_commit_id(heads[0]);
cl_assert_equal_i(1, git_oid_equal(id, &expected_id));
cl_git_pass(git_merge_head_from_id(&heads[1], repo, &expected_id));
id = git_merge_head_id(heads[1]);
cl_git_pass(git_annotated_commit_lookup(&heads[1], repo, &expected_id));
id = git_annotated_commit_id(heads[1]);
cl_assert_equal_i(1, git_oid_equal(id, &expected_id));
cl_git_pass(git_reference_lookup(&ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&heads[2], repo, ref));
id = git_merge_head_id(heads[2]);
cl_git_pass(git_annotated_commit_from_ref(&heads[2], repo, ref));
id = git_annotated_commit_id(heads[2]);
cl_assert_equal_i(1, git_oid_equal(id, &expected_id));
git_reference_free(ref);
git_merge_head_free(heads[0]);
git_merge_head_free(heads[1]);
git_merge_head_free(heads[2]);
git_annotated_commit_free(heads[0]);
git_annotated_commit_free(heads[1]);
git_annotated_commit_free(heads[2]);
}
struct merge_head_cb_data {
struct annotated_commit_cb_data {
const char **oid_str;
unsigned int len;
unsigned int i;
};
static int merge_head_foreach_cb(const git_oid *oid, void *payload)
static int annotated_commit_foreach_cb(const git_oid *oid, void *payload)
{
git_oid expected_oid;
struct merge_head_cb_data *cb_data = payload;
struct annotated_commit_cb_data *cb_data = payload;
git_oid_fromstr(&expected_oid, cb_data->oid_str[cb_data->i]);
cl_assert(git_oid_cmp(&expected_oid, oid) == 0);
......@@ -931,7 +931,7 @@ void test_merge_workdir_setup__head_notfound(void)
int error;
cl_git_fail((error = git_repository_mergehead_foreach(repo,
merge_head_foreach_cb, NULL)));
annotated_commit_foreach_cb, NULL)));
cl_assert(error == GIT_ENOTFOUND);
}
......@@ -942,7 +942,7 @@ void test_merge_workdir_setup__head_invalid_oid(void)
write_file_contents(GIT_MERGE_HEAD_FILE, "invalid-oid\n");
cl_git_fail((error = git_repository_mergehead_foreach(repo,
merge_head_foreach_cb, NULL)));
annotated_commit_foreach_cb, NULL)));
cl_assert(error == -1);
}
......@@ -953,7 +953,7 @@ void test_merge_workdir_setup__head_foreach_nonewline(void)
write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID);
cl_git_fail((error = git_repository_mergehead_foreach(repo,
merge_head_foreach_cb, NULL)));
annotated_commit_foreach_cb, NULL)));
cl_assert(error == -1);
}
......@@ -961,12 +961,12 @@ void test_merge_workdir_setup__head_foreach_one(void)
{
const char *expected = THEIRS_SIMPLE_OID;
struct merge_head_cb_data cb_data = { &expected, 1 };
struct annotated_commit_cb_data cb_data = { &expected, 1 };
write_file_contents(GIT_MERGE_HEAD_FILE, THEIRS_SIMPLE_OID "\n");
cl_git_pass(git_repository_mergehead_foreach(repo,
merge_head_foreach_cb, &cb_data));
annotated_commit_foreach_cb, &cb_data));
cl_assert(cb_data.i == cb_data.len);
}
......@@ -976,7 +976,7 @@ void test_merge_workdir_setup__head_foreach_octopus(void)
const char *expected[] = { THEIRS_SIMPLE_OID,
OCTO1_OID, OCTO2_OID, OCTO3_OID, OCTO4_OID, OCTO5_OID };
struct merge_head_cb_data cb_data = { expected, 6 };
struct annotated_commit_cb_data cb_data = { expected, 6 };
write_file_contents(GIT_MERGE_HEAD_FILE,
THEIRS_SIMPLE_OID "\n"
......@@ -987,7 +987,7 @@ void test_merge_workdir_setup__head_foreach_octopus(void)
OCTO5_OID "\n");
cl_git_pass(git_repository_mergehead_foreach(repo,
merge_head_foreach_cb, &cb_data));
annotated_commit_foreach_cb, &cb_data));
cl_assert(cb_data.i == cb_data.len);
}
......@@ -996,16 +996,16 @@ void test_merge_workdir_setup__retained_after_success(void)
{
git_oid our_oid;
git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1];
git_annotated_commit *our_head, *their_heads[1];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_merge(repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
......@@ -1014,27 +1014,27 @@ void test_merge_workdir_setup__retained_after_success(void)
git_reference_free(octo1_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
void test_merge_workdir_setup__removed_after_failure(void)
{
git_oid our_oid;
git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1];
git_annotated_commit *our_head, *their_heads[1];
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
cl_git_pass(git_annotated_commit_lookup(&our_head, repo, &our_oid));
cl_git_pass(git_reference_lookup(&octo1_ref, repo, GIT_REFS_HEADS_DIR OCTO1_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_rewritefile("merge-resolve/new-in-octo1.txt",
"Conflicting file!\n\nMerge will fail!\n");
cl_git_fail(git_merge(
repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
repo, (const git_annotated_commit **)&their_heads[0], 1, NULL, NULL));
cl_assert(!git_path_exists("merge-resolve/" GIT_MERGE_HEAD_FILE));
cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE));
......@@ -1043,6 +1043,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_reference_free(octo1_ref);
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(our_head);
git_annotated_commit_free(their_heads[0]);
}
......@@ -95,20 +95,20 @@ void test_merge_workdir_simple__cleanup(void)
static void merge_simple_branch(int merge_file_favor, int addl_checkout_strategy)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
git_annotated_commit *their_heads[1];
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_SIMPLE_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = merge_file_favor;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS |
addl_checkout_strategy;
cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, &checkout_opts));
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(their_heads[0]);
}
static void set_core_autocrlf_to(git_repository *repo, bool value)
......@@ -486,7 +486,7 @@ void test_merge_workdir_simple__directory_file(void)
{
git_reference *head;
git_oid their_oids[1], head_commit_id;
git_merge_head *their_heads[1];
git_annotated_commit *their_heads[1];
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_commit *head_commit;
......@@ -519,22 +519,22 @@ void test_merge_workdir_simple__directory_file(void)
cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD, NULL, NULL, NULL));
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_DIRECTORY_FILE));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = 0;
cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 20));
git_reference_free(head);
git_commit_free(head_commit);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(their_heads[0]);
}
void test_merge_workdir_simple__unrelated(void)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
git_annotated_commit *their_heads[1];
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = {
......@@ -550,20 +550,20 @@ void test_merge_workdir_simple__unrelated(void)
};
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_PARENT));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = 0;
cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 9));
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(their_heads[0]);
}
void test_merge_workdir_simple__unrelated_with_conflicts(void)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
git_annotated_commit *their_heads[1];
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = {
......@@ -581,21 +581,21 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
};
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_OID));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
cl_git_pass(git_annotated_commit_lookup(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = 0;
cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, &merge_opts, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 11));
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(their_heads[0]);
}
void test_merge_workdir_simple__binary(void)
{
git_oid our_oid, their_oid, our_file_oid;
git_commit *our_commit;
git_merge_head *their_head;
git_annotated_commit *their_head;
const git_index_entry *binary_entry;
struct merge_index_entry merge_index_entries[] = {
......@@ -610,9 +610,9 @@ void test_merge_workdir_simple__binary(void)
cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL, NULL));
cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
cl_git_pass(git_annotated_commit_lookup(&their_head, repo, &their_oid));
cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_head, 1, NULL, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 3));
......@@ -622,6 +622,6 @@ void test_merge_workdir_simple__binary(void)
cl_git_pass(git_oid_fromstr(&our_file_oid, "23ed141a6ae1e798b2f721afedbe947c119111ba"));
cl_assert(git_oid_cmp(&binary_entry->id, &our_file_oid) == 0);
git_merge_head_free(their_head);
git_annotated_commit_free(their_head);
git_commit_free(our_commit);
}
......@@ -30,7 +30,7 @@ void test_merge_workdir_submodules__automerge(void)
{
git_reference *our_ref, *their_ref;
git_commit *our_commit;
git_merge_head *their_head;
git_annotated_commit *their_head;
git_index *index;
struct merge_index_entry merge_index_entries[] = {
......@@ -47,15 +47,15 @@ void test_merge_workdir_submodules__automerge(void)
cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL, NULL));
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_head, 1, NULL, NULL));
cl_git_pass(git_repository_index(&index, repo));
cl_assert(merge_test_index(index, merge_index_entries, 6));
git_index_free(index);
git_merge_head_free(their_head);
git_annotated_commit_free(their_head);
git_commit_free(our_commit);
git_reference_free(their_ref);
git_reference_free(our_ref);
......@@ -65,7 +65,7 @@ void test_merge_workdir_submodules__take_changed(void)
{
git_reference *our_ref, *their_ref;
git_commit *our_commit;
git_merge_head *their_head;
git_annotated_commit *their_head;
git_index *index;
struct merge_index_entry merge_index_entries[] = {
......@@ -80,15 +80,15 @@ void test_merge_workdir_submodules__take_changed(void)
cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL, NULL));
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)&their_head, 1, NULL, NULL));
cl_git_pass(git_repository_index(&index, repo));
cl_assert(merge_test_index(index, merge_index_entries, 4));
git_index_free(index);
git_merge_head_free(their_head);
git_annotated_commit_free(their_head);
git_commit_free(our_commit);
git_reference_free(their_ref);
git_reference_free(our_ref);
......
......@@ -33,7 +33,7 @@ static int merge_trivial(const char *ours, const char *theirs)
git_buf branch_buf = GIT_BUF_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_reference *our_ref, *their_ref;
git_merge_head *their_heads[1];
git_annotated_commit *their_heads[1];
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
......@@ -45,14 +45,14 @@ static int merge_trivial(const char *ours, const char *theirs)
git_buf_clear(&branch_buf);
git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs);
cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, their_ref));
cl_git_pass(git_annotated_commit_from_ref(&their_heads[0], repo, their_ref));
cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
cl_git_pass(git_merge(repo, (const git_annotated_commit **)their_heads, 1, NULL, NULL));
git_buf_free(&branch_buf);
git_reference_free(our_ref);
git_reference_free(their_ref);
git_merge_head_free(their_heads[0]);
git_annotated_commit_free(their_heads[0]);
return 0;
}
......
......@@ -2,6 +2,7 @@
#include "git2/rebase.h"
#include "merge.h"
#include "posix.h"
#include "annotated_commit.h"
#include <fcntl.h>
......@@ -18,7 +19,7 @@ void test_rebase_abort__cleanup(void)
cl_git_sandbox_cleanup();
}
static void test_abort(git_merge_head *branch, git_merge_head *onto)
static void test_abort(git_annotated_commit *branch, git_annotated_commit *onto)
{
git_rebase *rebase;
git_reference *head_ref, *branch_ref = NULL;
......@@ -37,11 +38,11 @@ static void test_abort(git_merge_head *branch, git_merge_head *onto)
cl_git_pass(git_reference_lookup(&head_ref, repo, "HEAD"));
if (branch->ref_name == NULL)
cl_assert_equal_oid(git_merge_head_id(branch), git_reference_target(head_ref));
cl_assert_equal_oid(git_annotated_commit_id(branch), git_reference_target(head_ref));
else {
cl_assert_equal_s("refs/heads/beef", git_reference_symbolic_target(head_ref));
cl_git_pass(git_reference_lookup(&branch_ref, repo, git_reference_symbolic_target(head_ref)));
cl_assert_equal_oid(git_merge_head_id(branch), git_reference_target(branch_ref));
cl_assert_equal_oid(git_annotated_commit_id(branch), git_reference_target(branch_ref));
}
git_status_list_new(&statuslist, repo, NULL);
......@@ -52,8 +53,8 @@ static void test_abort(git_merge_head *branch, git_merge_head *onto)
cl_git_pass(git_reflog_read(&reflog, repo, "HEAD"));
cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
cl_assert_equal_oid(git_merge_head_id(onto), git_reflog_entry_id_old(reflog_entry));
cl_assert_equal_oid(git_merge_head_id(branch), git_reflog_entry_id_new(reflog_entry));
cl_assert_equal_oid(git_annotated_commit_id(onto), git_reflog_entry_id_old(reflog_entry));
cl_assert_equal_oid(git_annotated_commit_id(branch), git_reflog_entry_id_new(reflog_entry));
cl_assert_equal_s("rebase: aborting", git_reflog_entry_message(reflog_entry));
git_reflog_free(reflog);
......@@ -68,13 +69,13 @@ void test_rebase_abort__merge(void)
git_rebase *rebase;
git_reference *branch_ref, *onto_ref;
git_signature *signature;
git_merge_head *branch_head, *onto_head;
git_annotated_commit *branch_head, *onto_head;
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
......@@ -85,8 +86,8 @@ void test_rebase_abort__merge(void)
git_signature_free(signature);
git_merge_head_free(branch_head);
git_merge_head_free(onto_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(onto_head);
git_reference_free(branch_ref);
git_reference_free(onto_ref);
......@@ -99,13 +100,13 @@ void test_rebase_abort__detached_head(void)
git_oid branch_id;
git_reference *onto_ref;
git_signature *signature;
git_merge_head *branch_head, *onto_head;
git_annotated_commit *branch_head, *onto_head;
git_oid_fromstr(&branch_id, "b146bd7608eac53d9bf9e1a6963543588b555c64");
cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_id(&branch_head, repo, &branch_id));
cl_git_pass(git_merge_head_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_annotated_commit_lookup(&branch_head, repo, &branch_id));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
......@@ -116,8 +117,8 @@ void test_rebase_abort__detached_head(void)
git_signature_free(signature);
git_merge_head_free(branch_head);
git_merge_head_free(onto_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(onto_head);
git_reference_free(onto_ref);
git_rebase_free(rebase);
......@@ -128,13 +129,13 @@ void test_rebase_abort__old_style_head_file(void)
git_rebase *rebase;
git_reference *branch_ref, *onto_ref;
git_signature *signature;
git_merge_head *branch_head, *onto_head;
git_annotated_commit *branch_head, *onto_head;
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
......@@ -148,8 +149,8 @@ void test_rebase_abort__old_style_head_file(void)
git_signature_free(signature);
git_merge_head_free(branch_head);
git_merge_head_free(onto_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(onto_head);
git_reference_free(branch_ref);
git_reference_free(onto_ref);
......
......@@ -49,7 +49,7 @@ void test_rebase_iterator__iterates(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id;
......@@ -60,8 +60,8 @@ void test_rebase_iterator__iterates(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
test_operations(rebase, 0);
......@@ -100,8 +100,8 @@ void test_rebase_iterator__iterates(void)
cl_assert_equal_i(GIT_ITEROVER, error);
test_operations(rebase, 4);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......
......@@ -26,7 +26,7 @@ void test_rebase_merge__next(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_status_list *status_list;
......@@ -38,8 +38,8 @@ void test_rebase_merge__next(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -62,8 +62,8 @@ void test_rebase_merge__next(void)
cl_assert_equal_oid(&file1_id, &status_entry->head_to_index->new_file.id);
git_status_list_free(status_list);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -73,7 +73,7 @@ void test_rebase_merge__next_with_conflicts(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_status_list *status_list;
......@@ -105,8 +105,8 @@ void test_rebase_merge__next_with_conflicts(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/asparagus"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -128,8 +128,8 @@ void test_rebase_merge__next_with_conflicts(void)
cl_assert_equal_file(expected_merge, strlen(expected_merge), "rebase/asparagus.txt");
git_status_list_free(status_list);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -139,7 +139,7 @@ void test_rebase_merge__next_stops_with_iterover(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id;
......@@ -150,8 +150,8 @@ void test_rebase_merge__next_stops_with_iterover(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -181,8 +181,8 @@ void test_rebase_merge__next_stops_with_iterover(void)
cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/end");
cl_assert_equal_file("5\n", 2, "rebase/.git/rebase-merge/msgnum");
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -192,7 +192,7 @@ void test_rebase_merge__commit(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id, tree_id, parent_id;
......@@ -206,8 +206,8 @@ void test_rebase_merge__commit(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -243,8 +243,8 @@ void test_rebase_merge__commit(void)
git_reflog_free(reflog);
git_signature_free(author);
git_commit_free(commit);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -254,7 +254,7 @@ void test_rebase_merge__commit_updates_rewritten(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id;
......@@ -264,8 +264,8 @@ void test_rebase_merge__commit_updates_rewritten(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -282,8 +282,8 @@ void test_rebase_merge__commit_updates_rewritten(void)
"8d1f13f93c4995760ac07d129246ac1ff64c0be9 ba1f9b4fd5cf8151f7818be2111cc0869f1eb95a\n",
164, "rebase/.git/rebase-merge/rewritten");
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -293,7 +293,7 @@ void test_rebase_merge__commit_drops_already_applied(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id;
......@@ -304,8 +304,8 @@ void test_rebase_merge__commit_drops_already_applied(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/green_pea"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -323,8 +323,8 @@ void test_rebase_merge__commit_drops_already_applied(void)
"8d1f13f93c4995760ac07d129246ac1ff64c0be9 2ac4fb7b74c1287f6c792acad759e1ec01e18dae\n",
82, "rebase/.git/rebase-merge/rewritten");
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -334,7 +334,7 @@ void test_rebase_merge__finish(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref, *head_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id;
......@@ -347,8 +347,8 @@ void test_rebase_merge__finish(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/gravy"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -377,13 +377,13 @@ void test_rebase_merge__finish(void)
cl_git_pass(git_reflog_read(&reflog, repo, "refs/heads/gravy"));
cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
cl_assert_equal_oid(git_merge_head_id(branch_head), git_reflog_entry_id_old(reflog_entry));
cl_assert_equal_oid(git_annotated_commit_id(branch_head), git_reflog_entry_id_old(reflog_entry));
cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
cl_assert_equal_s("rebase finished: refs/heads/gravy onto f87d14a4a236582a0278a916340a793714256864", git_reflog_entry_message(reflog_entry));
git_reflog_free(reflog);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(head_ref);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
......@@ -396,7 +396,7 @@ static void test_copy_note(
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_commit *branch_commit;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
......@@ -409,8 +409,8 @@ static void test_copy_note(
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/gravy"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_reference_peel((git_object **)&branch_commit,
branch_ref, GIT_OBJ_COMMIT));
......@@ -442,8 +442,8 @@ static void test_copy_note(
git_note_free(note);
git_commit_free(branch_commit);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......
......@@ -29,15 +29,15 @@ void test_rebase_setup__blocked_when_in_progress(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
git_rebase_free(rebase);
......@@ -46,8 +46,8 @@ void test_rebase_setup__blocked_when_in_progress(void)
cl_git_fail(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
}
......@@ -57,7 +57,7 @@ void test_rebase_setup__merge(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_reference *head;
git_commit *head_commit;
git_oid head_id;
......@@ -67,8 +67,8 @@ void test_rebase_setup__merge(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -93,8 +93,8 @@ void test_rebase_setup__merge(void)
git_commit_free(head_commit);
git_reference_free(head);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -105,7 +105,7 @@ void test_rebase_setup__merge_root(void)
{
git_rebase *rebase;
git_reference *branch_ref, *onto_ref;
git_merge_head *branch_head, *onto_head;
git_annotated_commit *branch_head, *onto_head;
git_reference *head;
git_commit *head_commit;
git_oid head_id;
......@@ -115,8 +115,8 @@ void test_rebase_setup__merge_root(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, signature, NULL));
......@@ -141,8 +141,8 @@ void test_rebase_setup__merge_root(void)
git_commit_free(head_commit);
git_reference_free(head);
git_merge_head_free(branch_head);
git_merge_head_free(onto_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(onto_head);
git_reference_free(branch_ref);
git_reference_free(onto_ref);
git_rebase_free(rebase);
......@@ -153,7 +153,7 @@ void test_rebase_setup__merge_onto_and_upstream(void)
{
git_rebase *rebase;
git_reference *branch1_ref, *branch2_ref, *onto_ref;
git_merge_head *branch1_head, *branch2_head, *onto_head;
git_annotated_commit *branch1_head, *branch2_head, *onto_head;
git_reference *head;
git_commit *head_commit;
git_oid head_id;
......@@ -164,9 +164,9 @@ void test_rebase_setup__merge_onto_and_upstream(void)
cl_git_pass(git_reference_lookup(&branch2_ref, repo, "refs/heads/veal"));
cl_git_pass(git_reference_lookup(&onto_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch1_head, repo, branch1_ref));
cl_git_pass(git_merge_head_from_ref(&branch2_head, repo, branch2_ref));
cl_git_pass(git_merge_head_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch1_head, repo, branch1_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch2_head, repo, branch2_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch1_head, branch2_head, onto_head, signature, NULL));
......@@ -187,9 +187,9 @@ void test_rebase_setup__merge_onto_and_upstream(void)
git_commit_free(head_commit);
git_reference_free(head);
git_merge_head_free(branch1_head);
git_merge_head_free(branch2_head);
git_merge_head_free(onto_head);
git_annotated_commit_free(branch1_head);
git_annotated_commit_free(branch2_head);
git_annotated_commit_free(onto_head);
git_reference_free(branch1_ref);
git_reference_free(branch2_ref);
git_reference_free(onto_ref);
......@@ -202,7 +202,7 @@ void test_rebase_setup__branch_with_merges(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_reference *head;
git_commit *head_commit;
git_oid head_id;
......@@ -212,8 +212,8 @@ void test_rebase_setup__branch_with_merges(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/veal"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -238,8 +238,8 @@ void test_rebase_setup__branch_with_merges(void)
git_commit_free(head_commit);
git_reference_free(head);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -250,7 +250,7 @@ void test_rebase_setup__orphan_branch(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
git_reference *head;
git_commit *head_commit;
git_oid head_id;
......@@ -260,8 +260,8 @@ void test_rebase_setup__orphan_branch(void)
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/barley"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL));
......@@ -286,8 +286,8 @@ void test_rebase_setup__orphan_branch(void)
git_commit_free(head_commit);
git_reference_free(head);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
......@@ -299,20 +299,20 @@ static int rebase_is_blocked(void)
int error;
git_reference *branch_ref, *upstream_ref;
git_merge_head *branch_head, *upstream_head;
git_annotated_commit *branch_head, *upstream_head;
cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
error = git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, signature, NULL);
git_merge_head_free(branch_head);
git_merge_head_free(upstream_head);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment