summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-05-13 23:56:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-14 19:14:19 (GMT)
commit95983da6b461a4394117d4f9fcca211d7fc1403f (patch)
tree77bf92abab3f58b782d4e44b5883791c33ca9aad /merge-recursive.c
parent172e8ff696ea0ebe002bdd1f61a3544fc7f71a61 (diff)
downloadgit-95983da6b461a4394117d4f9fcca211d7fc1403f.zip
git-95983da6b461a4394117d4f9fcca211d7fc1403f.tar.gz
git-95983da6b461a4394117d4f9fcca211d7fc1403f.tar.bz2
merge-recursive: fix rename/rename(1to2) for working tree with a binary
With a rename/rename(1to2) conflict, we attempt to do a three-way merge of the file contents, so that the correct contents can be placed in the working tree at both paths. If the file is a binary, however, no content merging is possible and we should just use the original version of the file at each of the paths. Reported-by: Chunlin Zhang <zhangchunlin@gmail.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index d92e2ac..36948ea 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1750,6 +1750,18 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
return -1;
}
+ if (!mfi.clean && mfi.blob.mode == a->mode &&
+ oideq(&mfi.blob.oid, &a->oid)) {
+ /*
+ * Getting here means we were attempting to merge a binary
+ * blob. Since we can't merge binaries, the merge algorithm
+ * just takes one side. But we don't want to copy the
+ * contents of one side to both paths; we'd rather use the
+ * original content at the given path for each path.
+ */
+ oidcpy(&mfi.blob.oid, &b->oid);
+ mfi.blob.mode = b->mode;
+ }
add = &ci->ren2->dst_entry->stages[flip_stage(3)];
if (is_valid(add)) {
add->path = mfi.blob.path = b->path;