mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 18:38:58 +00:00
Capture conflict information in MERGE_MSG for revert and merge
This commit is contained in:
parent
103b7d2122
commit
6fefb7af84
@ -2662,6 +2662,7 @@ int git_merge(
|
|||||||
if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 ||
|
if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 ||
|
||||||
(error = git_merge__indexes(repo, index_new)) < 0 ||
|
(error = git_merge__indexes(repo, index_new)) < 0 ||
|
||||||
(error = git_repository_index(&index_repo, repo)) < 0 ||
|
(error = git_repository_index(&index_repo, repo)) < 0 ||
|
||||||
|
(error = git_merge__append_conflicts_to_merge_msg(repo, index_repo)) < 0 ||
|
||||||
(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;
|
||||||
|
|
||||||
|
@ -201,6 +201,7 @@ int git_revert(
|
|||||||
(error = git_revert_commit(&index_new, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 ||
|
(error = git_revert_commit(&index_new, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 ||
|
||||||
(error = git_merge__indexes(repo, index_new)) < 0 ||
|
(error = git_merge__indexes(repo, index_new)) < 0 ||
|
||||||
(error = git_repository_index(&index_repo, repo)) < 0 ||
|
(error = git_repository_index(&index_repo, repo)) < 0 ||
|
||||||
|
(error = git_merge__append_conflicts_to_merge_msg(repo, index_repo)) < 0 ||
|
||||||
(error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0)
|
(error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ void test_merge_workdir_simple__automerge_crlf(void)
|
|||||||
|
|
||||||
void test_merge_workdir_simple__mergefile(void)
|
void test_merge_workdir_simple__mergefile(void)
|
||||||
{
|
{
|
||||||
git_buf conflicting_buf = GIT_BUF_INIT;
|
git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT;
|
||||||
|
|
||||||
struct merge_index_entry merge_index_entries[] = {
|
struct merge_index_entry merge_index_entries[] = {
|
||||||
ADDED_IN_MASTER_INDEX_ENTRY,
|
ADDED_IN_MASTER_INDEX_ENTRY,
|
||||||
@ -240,7 +240,15 @@ void test_merge_workdir_simple__mergefile(void)
|
|||||||
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
|
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
|
||||||
TEST_REPO_PATH "/conflicting.txt"));
|
TEST_REPO_PATH "/conflicting.txt"));
|
||||||
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_MERGE_FILE) == 0);
|
cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_MERGE_FILE) == 0);
|
||||||
|
cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
|
||||||
|
TEST_REPO_PATH "/.git/MERGE_MSG"));
|
||||||
|
cl_assert(strcmp(git_buf_cstr(&mergemsg_buf),
|
||||||
|
"Merge commit '7cb63eed597130ba4abb87b3e544b85021905520'\n" \
|
||||||
|
"\n" \
|
||||||
|
"Conflicts:\n" \
|
||||||
|
"\tconflicting.txt\n") == 0);
|
||||||
git_buf_free(&conflicting_buf);
|
git_buf_free(&conflicting_buf);
|
||||||
|
git_buf_free(&mergemsg_buf);
|
||||||
|
|
||||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
|
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
|
||||||
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
|
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
|
||||||
|
@ -66,7 +66,7 @@ void test_revert_workdir__conflicts(void)
|
|||||||
git_reference *head_ref;
|
git_reference *head_ref;
|
||||||
git_commit *head, *commit;
|
git_commit *head, *commit;
|
||||||
git_oid revert_oid;
|
git_oid revert_oid;
|
||||||
git_buf conflicting_buf = GIT_BUF_INIT;
|
git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT;
|
||||||
|
|
||||||
struct merge_index_entry merge_index_entries[] = {
|
struct merge_index_entry merge_index_entries[] = {
|
||||||
{ 0100644, "7731926a337c4eaba1e2187d90ebfa0a93659382", 1, "file1.txt" },
|
{ 0100644, "7731926a337c4eaba1e2187d90ebfa0a93659382", 1, "file1.txt" },
|
||||||
@ -112,9 +112,21 @@ void test_revert_workdir__conflicts(void)
|
|||||||
"File one\n" \
|
"File one\n" \
|
||||||
">>>>>>> parent of 72333f4... automergeable changes\n") == 0);
|
">>>>>>> parent of 72333f4... automergeable changes\n") == 0);
|
||||||
|
|
||||||
|
cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
|
||||||
|
cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
|
||||||
|
TEST_REPO_PATH "/.git/MERGE_MSG"));
|
||||||
|
cl_assert(strcmp(mergemsg_buf.ptr,
|
||||||
|
"Revert \"automergeable changes\"\n" \
|
||||||
|
"\n" \
|
||||||
|
"This reverts commit 72333f47d4e83616630ff3b0ffe4c0faebcc3c45.\n"
|
||||||
|
"\n" \
|
||||||
|
"Conflicts:\n" \
|
||||||
|
"\tfile1.txt\n") == 0);
|
||||||
|
|
||||||
git_commit_free(commit);
|
git_commit_free(commit);
|
||||||
git_commit_free(head);
|
git_commit_free(head);
|
||||||
git_reference_free(head_ref);
|
git_reference_free(head_ref);
|
||||||
|
git_buf_free(&mergemsg_buf);
|
||||||
git_buf_free(&conflicting_buf);
|
git_buf_free(&conflicting_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user