Subject: Re: [PATCH] modify/delete conflict resolution overwrites untracked file

From: Clemens Buchacher <[email-masked]>
Date: Mon, 15 Dec 2008 01:46:51 +0100

On Wed, Dec 10, 2008 at 09:12:59PM +0100, Clemens Buchacher wrote:
> If a file was removed in HEAD, but modified in MERGE_HEAD, recursive merge
> will result in a "CONFLICT (delete/modify)". If the (now untracked) file
> already exists and was not added to the index, it is overwritten with the
> conflict resolution contents.

The following patch fixes the problem described above, but it also breaks
t6023-merge-rename-nocruft.sh, which tries to merge "A" renamed to "B" in
HEAD and "A" modified in MERGE_HEAD, while ignoring an untracked file "A" in
the working tree. If we want to be able to do this, we have to handle the
other case after rename detection.

---
 unpack-trees.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 54f301d..de5b616 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -859,6 +859,9 @@ int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o)
 	if (index) {
 		if (verify_uptodate(index, o))
 			return -1;
+	} else if (remote && !remote_match) {
+		if (verify_absent(remote, "overwritten", o))
+			return -1;
 	}
 
 	o->nontrivial_merge = 1;
-- 
1.6.1.rc2