Commit d9fdee6e by Edward Thomson

Remove `git_merge_result` as it's now unnecessary

parent 5aa2ac6d
...@@ -472,27 +472,11 @@ GIT_EXTERN(int) git_merge_commits( ...@@ -472,27 +472,11 @@ GIT_EXTERN(int) git_merge_commits(
const git_merge_options *opts); const git_merge_options *opts);
/** /**
* Merges the given commit(s) into HEAD and either returns immediately * Merges the given commit(s) into HEAD, writing the results into the working
* if there was no merge to perform (the specified commits have already * directory. Any changes are staged for commit and any conflicts are written
* been merged or would produce a fast-forward) or performs the merge * to the index. Callers should inspect the repository's index after this
* and writes the results into the working directory. * completes, resolve any conflicts and prepare a commit.
* *
* Callers should inspect the `git_merge_result`:
*
* If `git_merge_result_is_uptodate` is true, there is no work to perform.
*
* If `git_merge_result_is_fastforward` is true, the caller should update
* any necessary references to the commit ID returned by
* `git_merge_result_fastforward_id` and check that out in order to complete
* the fast-forward.
*
* Otherwise, callers should inspect the resulting index, resolve any
* conflicts and prepare a commit.
*
* The resultant `git_merge_result` should be free with
* `git_merge_result_free`.
*
* @param out the results of the merge
* @param repo the repository to merge * @param repo the repository to merge
* @param merge_heads the heads to merge into * @param merge_heads the heads to merge into
* @param merge_heads_len the number of heads to merge * @param merge_heads_len the number of heads to merge
...@@ -501,52 +485,12 @@ GIT_EXTERN(int) git_merge_commits( ...@@ -501,52 +485,12 @@ GIT_EXTERN(int) git_merge_commits(
* @return 0 on success or error code * @return 0 on success or error code
*/ */
GIT_EXTERN(int) git_merge( GIT_EXTERN(int) git_merge(
git_merge_result **out,
git_repository *repo, git_repository *repo,
const git_merge_head **their_heads, const git_merge_head **their_heads,
size_t their_heads_len, size_t their_heads_len,
const git_merge_options *merge_opts, const git_merge_options *merge_opts,
const git_checkout_options *checkout_opts); const git_checkout_options *checkout_opts);
/**
* Returns true if a merge is "up-to-date", meaning that the commit(s)
* that were provided to `git_merge` are already included in `HEAD`
* and there is no work to do.
*
* @return true if the merge is up-to-date, false otherwise
*/
GIT_EXTERN(int) git_merge_result_is_uptodate(git_merge_result *merge_result);
/**
* Returns true if a merge is eligible to be "fast-forwarded", meaning that
* the commit that was provided to `git_merge` need not be merged, it can
* simply be checked out, because the current `HEAD` is the merge base of
* itself and the given commit. To perform the fast-forward, the caller
* should check out the results of `git_merge_result_fastforward_id`.
*
* This will never be true if `GIT_MERGE_NO_FASTFORWARD` is supplied as
* a merge option.
*
* @return true if the merge is fast-forwardable, false otherwise
*/
GIT_EXTERN(int) git_merge_result_is_fastforward(git_merge_result *merge_result);
/**
* Gets the fast-forward OID if the merge was a fastforward.
*
* @param out pointer to populate with the OID of the fast-forward
* @param merge_result the results of the merge
* @return 0 on success or error code
*/
GIT_EXTERN(int) git_merge_result_fastforward_id(git_oid *out, git_merge_result *merge_result);
/**
* Frees a `git_merge_result`.
*
* @param result merge result to free
*/
GIT_EXTERN(void) git_merge_result_free(git_merge_result *merge_result);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
#endif #endif
...@@ -2548,14 +2548,12 @@ done: ...@@ -2548,14 +2548,12 @@ done:
} }
int git_merge( int git_merge(
git_merge_result **out,
git_repository *repo, git_repository *repo,
const git_merge_head **their_heads, const git_merge_head **their_heads,
size_t their_heads_len, size_t their_heads_len,
const git_merge_options *merge_opts, const git_merge_options *merge_opts,
const git_checkout_options *given_checkout_opts) const git_checkout_options *given_checkout_opts)
{ {
git_merge_result *result;
git_reference *our_ref = NULL; git_reference *our_ref = NULL;
git_checkout_options checkout_opts; git_checkout_options checkout_opts;
git_merge_head *ancestor_head = NULL, *our_head = NULL; git_merge_head *ancestor_head = NULL, *our_head = NULL;
...@@ -2564,18 +2562,13 @@ int git_merge( ...@@ -2564,18 +2562,13 @@ int git_merge(
size_t i; size_t i;
int error = 0; int error = 0;
assert(out && repo && their_heads); assert(repo && their_heads);
*out = NULL;
if (their_heads_len != 1) { if (their_heads_len != 1) {
giterr_set(GITERR_MERGE, "Can only merge a single branch"); giterr_set(GITERR_MERGE, "Can only merge a single branch");
return -1; return -1;
} }
result = git__calloc(1, sizeof(git_merge_result));
GITERR_CHECK_ALLOC(result);
their_trees = git__calloc(their_heads_len, sizeof(git_tree *)); their_trees = git__calloc(their_heads_len, sizeof(git_tree *));
GITERR_CHECK_ALLOC(their_trees); GITERR_CHECK_ALLOC(their_trees);
...@@ -2610,16 +2603,12 @@ int git_merge( ...@@ -2610,16 +2603,12 @@ int git_merge(
(error = git_checkout_index(repo, index_repo, &checkout_opts)) < 0) (error = git_checkout_index(repo, index_repo, &checkout_opts)) < 0)
goto on_error; goto on_error;
result->index = index_new;
*out = result;
goto done; goto done;
on_error: on_error:
merge_state_cleanup(repo); merge_state_cleanup(repo);
git_index_free(index_new); git_index_free(index_new);
git__free(result);
done: done:
git_index_free(index_repo); git_index_free(index_repo);
...@@ -2640,41 +2629,6 @@ done: ...@@ -2640,41 +2629,6 @@ done:
return error; return error;
} }
/* Merge result data */
int git_merge_result_is_uptodate(git_merge_result *merge_result)
{
assert(merge_result);
return merge_result->is_uptodate;
}
int git_merge_result_is_fastforward(git_merge_result *merge_result)
{
assert(merge_result);
return merge_result->is_fastforward;
}
int git_merge_result_fastforward_id(git_oid *out, git_merge_result *merge_result)
{
assert(out && merge_result);
git_oid_cpy(out, &merge_result->fastforward_oid);
return 0;
}
void git_merge_result_free(git_merge_result *merge_result)
{
if (merge_result == NULL)
return;
git_index_free(merge_result->index);
merge_result->index = NULL;
git__free(merge_result);
}
/* Merge heads are the input to merge */ /* Merge heads are the input to merge */
static int merge_head_init( static int merge_head_init(
......
...@@ -120,16 +120,6 @@ struct git_merge_head { ...@@ -120,16 +120,6 @@ struct git_merge_head {
git_commit *commit; git_commit *commit;
}; };
/** Internal structure for merge results */
struct git_merge_result {
bool is_uptodate;
bool is_fastforward;
git_oid fastforward_oid;
git_index *index;
};
int git_merge__bases_many( int git_merge__bases_many(
git_commit_list **out, git_commit_list **out,
git_revwalk *walk, git_revwalk *walk,
......
...@@ -79,7 +79,7 @@ int merge_commits_from_branches( ...@@ -79,7 +79,7 @@ int merge_commits_from_branches(
return 0; return 0;
} }
int merge_branches(git_merge_result **result, git_repository *repo, int merge_branches(git_repository *repo,
const char *ours_branch, const char *theirs_branch, const char *ours_branch, const char *theirs_branch,
git_merge_options *merge_opts, git_checkout_options *checkout_opts) git_merge_options *merge_opts, git_checkout_options *checkout_opts)
{ {
...@@ -95,7 +95,7 @@ int merge_branches(git_merge_result **result, git_repository *repo, ...@@ -95,7 +95,7 @@ int merge_branches(git_merge_result **result, git_repository *repo,
cl_git_pass(git_reference_lookup(&theirs_ref, repo, theirs_branch)); 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_merge_head_from_ref(&theirs_head, repo, theirs_ref));
cl_git_pass(git_merge(result, repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts)); cl_git_pass(git_merge(repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
git_reference_free(head_ref); git_reference_free(head_ref);
git_reference_free(theirs_ref); git_reference_free(theirs_ref);
......
...@@ -92,7 +92,7 @@ int merge_commits_from_branches( ...@@ -92,7 +92,7 @@ int merge_commits_from_branches(
const char *ours_name, const char *theirs_name, const char *ours_name, const char *theirs_name,
git_merge_options *opts); git_merge_options *opts);
int merge_branches(git_merge_result **result, git_repository *repo, int merge_branches(git_repository *repo,
const char *ours_branch, const char *theirs_branch, const char *ours_branch, const char *theirs_branch,
git_merge_options *merge_opts, git_checkout_options *checkout_opts); git_merge_options *merge_opts, git_checkout_options *checkout_opts);
......
...@@ -86,7 +86,7 @@ static void set_core_autocrlf_to(git_repository *repo, bool value) ...@@ -86,7 +86,7 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
git_config_free(cfg); git_config_free(cfg);
} }
static int merge_branch(git_merge_result **result, int merge_file_favor, int checkout_strategy) static int merge_branch(int merge_file_favor, int checkout_strategy)
{ {
git_oid their_oids[1]; git_oid their_oids[1];
git_merge_head *their_heads[1]; git_merge_head *their_heads[1];
...@@ -99,7 +99,7 @@ static int merge_branch(git_merge_result **result, int merge_file_favor, int che ...@@ -99,7 +99,7 @@ static int merge_branch(git_merge_result **result, int merge_file_favor, int che
merge_opts.file_favor = merge_file_favor; merge_opts.file_favor = merge_file_favor;
checkout_opts.checkout_strategy = checkout_strategy; checkout_opts.checkout_strategy = checkout_strategy;
error = git_merge(result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts); error = git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
git_merge_head_free(their_heads[0]); git_merge_head_free(their_heads[0]);
...@@ -177,7 +177,6 @@ static void stage_content(char *content[]) ...@@ -177,7 +177,6 @@ static void stage_content(char *content[])
{ {
git_reference *head; git_reference *head;
git_object *head_object; git_object *head_object;
git_merge_result *result = NULL;
git_buf path = GIT_BUF_INIT; git_buf path = GIT_BUF_INIT;
char *filename, *text; char *filename, *text;
size_t i; size_t i;
...@@ -198,7 +197,6 @@ static void stage_content(char *content[]) ...@@ -198,7 +197,6 @@ static void stage_content(char *content[])
cl_git_pass(git_index_add_bypath(repo_index, filename)); cl_git_pass(git_index_add_bypath(repo_index, filename));
} }
git_merge_result_free(result);
git_object_free(head_object); git_object_free(head_object);
git_reference_free(head); git_reference_free(head);
git_buf_free(&path); git_buf_free(&path);
...@@ -208,7 +206,6 @@ static int merge_dirty_files(char *dirty_files[]) ...@@ -208,7 +206,6 @@ static int merge_dirty_files(char *dirty_files[])
{ {
git_reference *head; git_reference *head;
git_object *head_object; git_object *head_object;
git_merge_result *result = NULL;
int error; int error;
cl_git_pass(git_repository_head(&head, repo)); cl_git_pass(git_repository_head(&head, repo));
...@@ -217,9 +214,8 @@ static int merge_dirty_files(char *dirty_files[]) ...@@ -217,9 +214,8 @@ static int merge_dirty_files(char *dirty_files[])
write_files(dirty_files); write_files(dirty_files);
error = merge_branch(&result, 0, 0); error = merge_branch(0, 0);
git_merge_result_free(result);
git_object_free(head_object); git_object_free(head_object);
git_reference_free(head); git_reference_free(head);
...@@ -230,7 +226,6 @@ static int merge_differently_filtered_files(char *files[]) ...@@ -230,7 +226,6 @@ static int merge_differently_filtered_files(char *files[])
{ {
git_reference *head; git_reference *head;
git_object *head_object; git_object *head_object;
git_merge_result *result = NULL;
int error; int error;
cl_git_pass(git_repository_head(&head, repo)); cl_git_pass(git_repository_head(&head, repo));
...@@ -242,9 +237,8 @@ static int merge_differently_filtered_files(char *files[]) ...@@ -242,9 +237,8 @@ static int merge_differently_filtered_files(char *files[])
cl_git_pass(git_index_write(repo_index)); cl_git_pass(git_index_write(repo_index));
error = merge_branch(&result, 0, 0); error = merge_branch(0, 0);
git_merge_result_free(result);
git_object_free(head_object); git_object_free(head_object);
git_reference_free(head); git_reference_free(head);
...@@ -252,17 +246,9 @@ static int merge_differently_filtered_files(char *files[]) ...@@ -252,17 +246,9 @@ static int merge_differently_filtered_files(char *files[])
} }
static int merge_staged_files(char *staged_files[]) static int merge_staged_files(char *staged_files[])
{ {
git_merge_result *result = NULL;
int error;
stage_random_files(staged_files); stage_random_files(staged_files);
return merge_branch(0, 0);
error = merge_branch(&result, 0, 0);
git_merge_result_free(result);
return error;
} }
void test_merge_workdir_dirty__unaffected_dirty_files_allowed(void) void test_merge_workdir_dirty__unaffected_dirty_files_allowed(void)
...@@ -297,7 +283,6 @@ void test_merge_workdir_dirty__staged_files_in_index_disallowed(void) ...@@ -297,7 +283,6 @@ void test_merge_workdir_dirty__staged_files_in_index_disallowed(void)
void test_merge_workdir_dirty__identical_staged_files_allowed(void) void test_merge_workdir_dirty__identical_staged_files_allowed(void)
{ {
git_merge_result *result;
char **content; char **content;
size_t i; size_t i;
...@@ -307,9 +292,7 @@ void test_merge_workdir_dirty__identical_staged_files_allowed(void) ...@@ -307,9 +292,7 @@ void test_merge_workdir_dirty__identical_staged_files_allowed(void)
stage_content(content); stage_content(content);
git_index_write(repo_index); git_index_write(repo_index);
cl_git_pass(merge_branch(&result, 0, 0)); cl_git_pass(merge_branch(0, 0));
git_merge_result_free(result);
} }
} }
......
...@@ -34,7 +34,6 @@ void test_merge_workdir_renames__cleanup(void) ...@@ -34,7 +34,6 @@ void test_merge_workdir_renames__cleanup(void)
void test_merge_workdir_renames__renames(void) void test_merge_workdir_renames__renames(void)
{ {
git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT; git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
...@@ -67,16 +66,13 @@ void test_merge_workdir_renames__renames(void) ...@@ -67,16 +66,13 @@ void test_merge_workdir_renames__renames(void)
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES; merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
merge_opts.rename_threshold = 50; merge_opts.rename_threshold = 50;
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL)); cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
cl_assert(merge_test_workdir(repo, merge_index_entries, 24)); cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
git_merge_result_free(result);
} }
void test_merge_workdir_renames__ours(void) void test_merge_workdir_renames__ours(void)
{ {
git_index *index; git_index *index;
git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT; git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
...@@ -107,18 +103,16 @@ void test_merge_workdir_renames__ours(void) ...@@ -107,18 +103,16 @@ void test_merge_workdir_renames__ours(void)
merge_opts.rename_threshold = 50; merge_opts.rename_threshold = 50;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS; checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS;
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, &checkout_opts)); cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, &checkout_opts));
cl_git_pass(git_repository_index(&index, repo)); cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_index_write(index)); cl_git_pass(git_index_write(index));
cl_assert(merge_test_workdir(repo, merge_index_entries, 20)); cl_assert(merge_test_workdir(repo, merge_index_entries, 20));
git_merge_result_free(result);
git_index_free(index); git_index_free(index);
} }
void test_merge_workdir_renames__similar(void) void test_merge_workdir_renames__similar(void)
{ {
git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT; git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
/* /*
...@@ -156,9 +150,7 @@ void test_merge_workdir_renames__similar(void) ...@@ -156,9 +150,7 @@ void test_merge_workdir_renames__similar(void)
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES; merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
merge_opts.rename_threshold = 50; merge_opts.rename_threshold = 50;
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL)); cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
cl_assert(merge_test_workdir(repo, merge_index_entries, 24)); cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
git_merge_result_free(result);
} }
...@@ -970,7 +970,6 @@ void test_merge_workdir_setup__retained_after_success(void) ...@@ -970,7 +970,6 @@ void test_merge_workdir_setup__retained_after_success(void)
git_oid our_oid; git_oid our_oid;
git_reference *octo1_ref; git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1]; git_merge_head *our_head, *their_heads[1];
git_merge_result *result;
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD)); 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_merge_head_from_id(&our_head, repo, &our_oid));
...@@ -979,7 +978,7 @@ void test_merge_workdir_setup__retained_after_success(void) ...@@ -979,7 +978,7 @@ void test_merge_workdir_setup__retained_after_success(void)
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref)); cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL)); cl_git_pass(git_merge(repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n")); 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_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
...@@ -990,7 +989,6 @@ void test_merge_workdir_setup__retained_after_success(void) ...@@ -990,7 +989,6 @@ void test_merge_workdir_setup__retained_after_success(void)
git_merge_head_free(our_head); git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]); git_merge_head_free(their_heads[0]);
git_merge_result_free(result);
} }
void test_merge_workdir_setup__removed_after_failure(void) void test_merge_workdir_setup__removed_after_failure(void)
...@@ -998,7 +996,6 @@ void test_merge_workdir_setup__removed_after_failure(void) ...@@ -998,7 +996,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_oid our_oid; git_oid our_oid;
git_reference *octo1_ref; git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1]; git_merge_head *our_head, *their_heads[1];
git_merge_result *result;
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD)); 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_merge_head_from_id(&our_head, repo, &our_oid));
...@@ -1010,7 +1007,7 @@ void test_merge_workdir_setup__removed_after_failure(void) ...@@ -1010,7 +1007,7 @@ void test_merge_workdir_setup__removed_after_failure(void)
"Conflicting file!\n\nMerge will fail!\n"); "Conflicting file!\n\nMerge will fail!\n");
cl_git_fail(git_merge( cl_git_fail(git_merge(
&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL)); repo, (const git_merge_head **)&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_MERGE_HEAD_FILE));
cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE)); cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE));
...@@ -1021,5 +1018,4 @@ void test_merge_workdir_setup__removed_after_failure(void) ...@@ -1021,5 +1018,4 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_merge_head_free(our_head); git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]); git_merge_head_free(their_heads[0]);
git_merge_result_free(result);
} }
...@@ -31,7 +31,6 @@ void test_merge_workdir_submodules__automerge(void) ...@@ -31,7 +31,6 @@ void test_merge_workdir_submodules__automerge(void)
git_reference *our_ref, *their_ref; git_reference *our_ref, *their_ref;
git_commit *our_commit; git_commit *our_commit;
git_merge_head *their_head; git_merge_head *their_head;
git_merge_result *result;
git_index *index; git_index *index;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
...@@ -50,13 +49,12 @@ void test_merge_workdir_submodules__automerge(void) ...@@ -50,13 +49,12 @@ void test_merge_workdir_submodules__automerge(void)
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH)); 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_merge_head_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL)); cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_repository_index(&index, repo)); cl_git_pass(git_repository_index(&index, repo));
cl_assert(merge_test_index(index, merge_index_entries, 6)); cl_assert(merge_test_index(index, merge_index_entries, 6));
git_index_free(index); git_index_free(index);
git_merge_result_free(result);
git_merge_head_free(their_head); git_merge_head_free(their_head);
git_commit_free(our_commit); git_commit_free(our_commit);
git_reference_free(their_ref); git_reference_free(their_ref);
...@@ -68,7 +66,6 @@ void test_merge_workdir_submodules__take_changed(void) ...@@ -68,7 +66,6 @@ void test_merge_workdir_submodules__take_changed(void)
git_reference *our_ref, *their_ref; git_reference *our_ref, *their_ref;
git_commit *our_commit; git_commit *our_commit;
git_merge_head *their_head; git_merge_head *their_head;
git_merge_result *result;
git_index *index; git_index *index;
struct merge_index_entry merge_index_entries[] = { struct merge_index_entry merge_index_entries[] = {
...@@ -85,13 +82,12 @@ void test_merge_workdir_submodules__take_changed(void) ...@@ -85,13 +82,12 @@ void test_merge_workdir_submodules__take_changed(void)
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH)); 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_merge_head_from_ref(&their_head, repo, their_ref));
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL)); cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_repository_index(&index, repo)); cl_git_pass(git_repository_index(&index, repo));
cl_assert(merge_test_index(index, merge_index_entries, 4)); cl_assert(merge_test_index(index, merge_index_entries, 4));
git_index_free(index); git_index_free(index);
git_merge_result_free(result);
git_merge_head_free(their_head); git_merge_head_free(their_head);
git_commit_free(our_commit); git_commit_free(our_commit);
git_reference_free(their_ref); git_reference_free(their_ref);
......
...@@ -34,7 +34,6 @@ static int merge_trivial(const char *ours, const char *theirs) ...@@ -34,7 +34,6 @@ static int merge_trivial(const char *ours, const char *theirs)
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_reference *our_ref, *their_ref; git_reference *our_ref, *their_ref;
git_merge_head *their_heads[1]; git_merge_head *their_heads[1];
git_merge_result *result;
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE; checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
...@@ -48,13 +47,12 @@ static int merge_trivial(const char *ours, const char *theirs) ...@@ -48,13 +47,12 @@ static int merge_trivial(const char *ours, const char *theirs)
cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr)); 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_merge_head_from_ref(&their_heads[0], repo, their_ref));
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, NULL, NULL)); cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
git_buf_free(&branch_buf); git_buf_free(&branch_buf);
git_reference_free(our_ref); git_reference_free(our_ref);
git_reference_free(their_ref); git_reference_free(their_ref);
git_merge_head_free(their_heads[0]); git_merge_head_free(their_heads[0]);
git_merge_result_free(result);
return 0; return 0;
} }
......
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