summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-05-20 08:33:27 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-05-20 08:33:27 -0700
commitabbd1d9ebf9033924153c7a0f0abb37e7c8e50fd (patch)
treecaea3081d1e04556c08f69522d15f2b478a12be1 /merge-recursive.c
parentMerge branch 'cb/no-more-gmtime' (diff)
parentmerge-recursive: fix rename/rename(1to2) for working tree with a binary (diff)
downloadtgif-abbd1d9ebf9033924153c7a0f0abb37e7c8e50fd.tar.xz
Merge branch 'en/merge-rename-rename-worktree-fix'
When a binary file gets modified and renamed on both sides of history to different locations, both files would be written to the working tree but both would have the contents from "ours". This has been corrected so that the path from each side gets their original content. * en/merge-rename-rename-worktree-fix: merge-recursive: fix rename/rename(1to2) for working tree with a binary
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 d92e2acf1e..36948eafb7 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;