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;
}
......
......@@ -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);
......
......@@ -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