git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: [PATCH 27/37] merge-recursive: Move handling of double rename of one file to two
Date: Mon, 20 Sep 2010 02:29:00 -0600	[thread overview]
Message-ID: <1284971350-30590-28-git-send-email-newren@gmail.com> (raw)
In-Reply-To: <1284971350-30590-1-git-send-email-newren@gmail.com>

Move the handling of rename/rename conflicts where one file is renamed to
two different files, from process_renames() to process_df_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-recursive.c       |   57 +++++++++++++++++++++++++++++++++-------------
 t/t6022-merge-rename.sh |    2 +-
 2 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 178bbd8..e219d62 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -855,8 +855,11 @@ static void conflict_rename_rename_1to2(struct merge_options *o,
 		 * update_file(o, 0, pair2->two->sha1, pair2->two->mode, dst_name2);
 		 */
 	} else {
-		update_stages(dst_name1, NULL, pair1->two, NULL, 1);
-		update_stages(dst_name2, NULL, NULL, pair2->two, 1);
+		update_stages(ren1_dst, NULL, pair1->two, NULL, 1);
+		update_stages(ren2_dst, NULL, NULL, pair2->two, 1);
+
+		update_file(o, 0, pair1->two->sha1, pair1->two->mode, dst_name1);
+		update_file(o, 0, pair2->two->sha1, pair2->two->mode, dst_name2);
 	}
 	while (delp--)
 		free(del[delp]);
@@ -958,19 +961,15 @@ static int process_renames(struct merge_options *o,
 			ren2->dst_entry->processed = 1;
 			ren2->processed = 1;
 			if (strcmp(ren1_dst, ren2_dst) != 0) {
-				clean_merge = 0;
-				output(o, 1, "CONFLICT (rename/rename): "
-				       "Rename \"%s\"->\"%s\" in branch \"%s\" "
-				       "rename \"%s\"->\"%s\" in \"%s\"%s",
-				       src, ren1_dst, branch1,
-				       src, ren2_dst, branch2,
-				       o->call_depth ? " (left unresolved)": "");
-				if (o->call_depth) {
-					remove_file_from_cache(src);
-					update_file(o, 0, ren1->pair->one->sha1,
-						    ren1->pair->one->mode, src);
-				}
-				conflict_rename_rename_1to2(o, ren1->pair, branch1, ren2->pair, branch2);
+				setup_rename_df_conflict_info(RENAME_ONE_FILE_TO_TWO,
+							      ren1->pair,
+							      ren2->pair,
+							      branch1,
+							      branch2,
+							      ren1->dst_entry,
+							      ren2->dst_entry);
+				remove_file(o, 0, ren1_dst, 0);
+				/* ren2_dst not in head, so no need to delete */
 			} else {
 				struct merge_file_info mfi;
 				remove_file(o, 1, ren1_src, 1);
@@ -1364,7 +1363,33 @@ static int process_df_entry(struct merge_options *o,
 
 	entry->processed = 1;
 	if (entry->rename_df_conflict_info) {
-		die ("Not yet implemented.");
+		struct rename_df_conflict_info *conflict_info = entry->rename_df_conflict_info;
+		char *src;
+		switch (conflict_info->rename_type) {
+		case RENAME_ONE_FILE_TO_TWO:
+			src = conflict_info->pair1->one->path;
+			clean_merge = 0;
+			output(o, 1, "CONFLICT (rename/rename): "
+			       "Rename \"%s\"->\"%s\" in branch \"%s\" "
+			       "rename \"%s\"->\"%s\" in \"%s\"%s",
+			       src, conflict_info->pair1->two->path, conflict_info->branch1,
+			       src, conflict_info->pair2->two->path, conflict_info->branch2,
+			       o->call_depth ? " (left unresolved)": "");
+			if (o->call_depth) {
+				remove_file_from_cache(src);
+				update_file(o, 0, conflict_info->pair1->one->sha1,
+					    conflict_info->pair1->one->mode, src);
+			}
+			conflict_rename_rename_1to2(o, conflict_info->pair1,
+						    conflict_info->branch1,
+						    conflict_info->pair2,
+						    conflict_info->branch2);
+			conflict_info->dst_entry2->processed = 1;
+			break;
+		default:
+			entry->processed = 0;
+			break;
+		}
 	} else if (!o_sha && !!a_sha != !!b_sha) {
 		/* directory -> (directory, file) */
 		const char *add_branch;
diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh
index 02dea16..1f29c0a 100755
--- a/t/t6022-merge-rename.sh
+++ b/t/t6022-merge-rename.sh
@@ -652,7 +652,7 @@ test_expect_success 'setup rename of one file to two, with directories in the wa
 	git commit -m "Put one/file in the way, rename to two"
 '
 
-test_expect_failure 'check handling of differently renamed file with D/F conflicts' '
+test_expect_success 'check handling of differently renamed file with D/F conflicts' '
 	git checkout -q first-rename^0 &&
 	test_must_fail git merge --strategy=recursive second-rename &&
 
-- 
1.7.3.271.g16009

  parent reply	other threads:[~2010-09-20  8:30 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20  8:28 [PATCH 00/37] Audit and fix corner case bugs in recursive merge Elijah Newren
2010-09-20  8:28 ` [PATCH 01/37] t3030: Add a testcase for resolvable rename/add conflict with symlinks Elijah Newren
2010-09-20  9:15   ` Johannes Sixt
2010-09-20  9:34   ` Jakub Narebski
2010-09-20  8:28 ` [PATCH 02/37] merge-recursive: Restructure showing how to chain more process_* functions Elijah Newren
2010-09-20  8:28 ` [PATCH 03/37] t6032: Add a test checking for excessive output from merge Elijah Newren
2010-09-20  8:28 ` [PATCH 04/37] t6022: Add test combinations of {content conflict?, D/F conflict remains?} Elijah Newren
2010-09-20  8:28 ` [PATCH 05/37] t6022: Add tests for reversing order of merges when D/F conflicts present Elijah Newren
2010-09-20  8:28 ` [PATCH 06/37] t6022: Add tests with both rename source & dest involved in D/F conflicts Elijah Newren
2010-09-20  8:28 ` [PATCH 07/37] t6022: Add paired rename+D/F conflict: (two/file, one/file) -> (one, two) Elijah Newren
2010-09-20  8:28 ` [PATCH 08/37] t6022: Add tests for rename/rename combined with D/F conflicts Elijah Newren
2010-09-20  8:28 ` [PATCH 09/37] t6020: Modernize style a bit Elijah Newren
2010-09-20  9:24   ` Johannes Sixt
2010-09-20 16:03     ` Elijah Newren
2010-09-22  1:44       ` Junio C Hamano
2010-09-22  4:41         ` Elijah Newren
2010-09-20  8:28 ` [PATCH 10/37] t6020: Add a testcase for modify/delete + directory/file conflict Elijah Newren
2010-09-20  8:28 ` [PATCH 11/37] t6036: Test index and worktree state, not just that merge fails Elijah Newren
2010-09-20  8:28 ` [PATCH 12/37] t6036: Add a second testcase similar to the first but with content changes Elijah Newren
2010-09-20  8:28 ` [PATCH 13/37] t6036: Add testcase for undetected conflict Elijah Newren
2010-09-20  8:28 ` [PATCH 14/37] merge-recursive: Small code clarification -- variable name and comments Elijah Newren
2010-09-20  8:28 ` [PATCH 15/37] merge-recursive: Rename conflict_rename_rename*() for clarity Elijah Newren
2010-09-20  8:28 ` [PATCH 16/37] merge-recursive: Nuke rename/directory conflict detection Elijah Newren
2010-09-20  8:28 ` [PATCH 17/37] merge-recursive: Move rename/delete handling into dedicated function Elijah Newren
2010-09-20  8:28 ` [PATCH 18/37] merge-recursive: Move delete/modify " Elijah Newren
2010-09-20  8:28 ` [PATCH 19/37] merge-recursive: Move process_entry's content merging into a function Elijah Newren
2010-09-20  8:28 ` [PATCH 20/37] merge-recursive: New data structures for deferring of D/F conflicts Elijah Newren
2010-09-20  8:28 ` [PATCH 21/37] merge-recursive: New function to assist resolving renames in-core only Elijah Newren
2010-09-20  8:28 ` [PATCH 22/37] merge-recursive: Have process_entry() skip D/F or rename entries Elijah Newren
2010-09-20  8:28 ` [PATCH 23/37] merge-recursive: Structure process_df_entry() to handle more cases Elijah Newren
2010-09-20  8:28 ` [PATCH 24/37] merge-recursive: Update conflict_rename_rename_1to2() call signature Elijah Newren
2010-09-20  8:28 ` [PATCH 25/37] merge-recursive: Update merge_content() " Elijah Newren
2010-09-20  8:28 ` [PATCH 26/37] merge-recursive: Avoid doubly merging rename/add conflict contents Elijah Newren
2010-09-20  8:29 ` Elijah Newren [this message]
2010-09-20  8:29 ` [PATCH 28/37] merge-recursive: Move handling of double rename of one file to other file Elijah Newren
2010-09-20  8:29 ` [PATCH 29/37] merge-recursive: Delay handling of rename/delete conflicts Elijah Newren
2010-09-20  8:29 ` [PATCH 30/37] merge-recursive: Delay content merging for renames Elijah Newren
2010-09-20  8:29 ` [PATCH 31/37] merge-recursive: Delay modify/delete conflicts if D/F conflict present Elijah Newren
2010-09-20  8:29 ` [PATCH 32/37] conflict_rename_delete(): Check whether D/F conflicts are still present Elijah Newren
2010-09-20  8:29 ` [PATCH 33/37] conflict_rename_rename_1to2(): Fix checks for presence of D/F conflicts Elijah Newren
2010-09-20  8:29 ` [PATCH 34/37] merge_content(): Check whether D/F conflicts are still present Elijah Newren
2010-09-20  8:29 ` [PATCH 35/37] handle_delete_modify(): " Elijah Newren
2010-09-20  8:29 ` [PATCH 36/37] merge-recursive: Make room for directories in D/F conflicts Elijah Newren
2010-09-20 11:40   ` Johannes Sixt
2010-09-20 16:06     ` Elijah Newren
2010-09-20  8:29 ` [PATCH 37/37] merge-recursive: Remove redundant path clearing for " Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1284971350-30590-28-git-send-email-newren@gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).