Unverified Commit 4f5653a4 by Edward Thomson Committed by GitHub

Merge pull request #6060 from ccstolley/ccs_merge_bugfix

merge: Check file mode when resolving renames
parents 3f36e796 516f7519
...@@ -816,8 +816,11 @@ static int merge_conflict_resolve_one_renamed( ...@@ -816,8 +816,11 @@ static int merge_conflict_resolve_one_renamed(
conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED) conflict->type == GIT_MERGE_DIFF_RENAMED_ADDED)
return 0; return 0;
ours_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->our_entry.id) != 0); ours_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->our_entry.id) != 0) ||
theirs_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->their_entry.id) != 0); (conflict->ancestor_entry.mode != conflict->our_entry.mode);
theirs_changed = (git_oid__cmp(&conflict->ancestor_entry.id, &conflict->their_entry.id) != 0) ||
(conflict->ancestor_entry.mode != conflict->their_entry.mode);
/* if both are modified (and not to a common target) require a merge */ /* if both are modified (and not to a common target) require a merge */
if (ours_changed && theirs_changed && if (ours_changed && theirs_changed &&
......
[core]
repositoryformatversion = 0
filemode = true
bare = true
logallrefupdates = true
P pack-4363774fb90141e8aa7a326ace0566366114e869.pack
# pack-refs with: peeled fully-peeled sorted
ecef6a85173b6f446873a13f7b5a7b54a85cd912 refs/heads/master
ecef6a85173b6f446873a13f7b5a7b54a85cd912
#include "clar.h"
#include "clar_libgit2.h"
#include "git2/revert.h"
#include "../merge/merge_helpers.h"
#define TEST_REPO_PATH "revert-rename.git"
static git_repository *repo;
/* Fixture setup and teardown */
void test_revert_rename__initialize(void)
{
repo = cl_git_sandbox_init(TEST_REPO_PATH);
}
void test_revert_rename__cleanup(void)
{
cl_git_sandbox_cleanup();
}
/* Attempt a revert when there is a file rename AND change of file mode,
* but the file contents remain the same. Check that the file mode doesn't
* change following the revert.
*/
void test_revert_rename__automerge(void)
{
git_commit *head_commit, *revert_commit;
git_oid revert_oid;
git_index *index;
git_reference *head_ref;
struct merge_index_entry merge_index_entries[] = {
{ 0100644, "f0f64c618e1646d2948a456ed7c4bcfad5536d68", 0, "goodmode" }};
cl_git_pass(git_repository_head(&head_ref, repo));
cl_git_pass(git_reference_peel((git_object **)&head_commit, head_ref, GIT_OBJECT_COMMIT));
cl_git_pass(git_oid_fromstr(&revert_oid, "7b4d7c3789b3581973c04087cb774c3c3576de2f"));
cl_git_pass(git_commit_lookup(&revert_commit, repo, &revert_oid));
cl_git_pass(git_revert_commit(&index, repo, revert_commit, head_commit, 0, NULL));
cl_assert(merge_test_index(index, merge_index_entries, 1));
git_commit_free(revert_commit);
git_commit_free(head_commit);
git_index_free(index);
git_reference_free(head_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