All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Phillip Wood <phillip.wood@dunelm.org.uk>,
	Linus Nilsson <Linus.Nilsson@trimma.se>,
	Elijah Newren <newren@gmail.com>
Subject: [PATCH v2 08/15] merge-recursive: remove ren[12]_other fields from rename_conflict_info
Date: Fri, 29 Mar 2019 17:33:29 -0700	[thread overview]
Message-ID: <20190330003336.21940-9-newren@gmail.com> (raw)
In-Reply-To: <20190330003336.21940-1-newren@gmail.com>

The ren1_other and ren2_other fields were synthesized from information
in ren1->src_entry and ren2->src_entry.  Since we already have the
necessary information in ren1 and ren2, just use those.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-recursive.c | 71 ++++++++++++++---------------------------------
 1 file changed, 21 insertions(+), 50 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index e05f8f22f5..e66b47cfa1 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -242,8 +242,6 @@ struct rename_conflict_info {
 	struct rename *ren2;
 	const char *branch1;
 	const char *branch2;
-	struct diff_filespec ren1_other;
-	struct diff_filespec ren2_other;
 };
 
 static inline void setup_rename_conflict_info(enum rename_type rename_type,
@@ -251,11 +249,8 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
 					      struct rename *ren1,
 					      struct rename *ren2,
 					      const char *branch1,
-					      const char *branch2,
-					      struct stage_data *src_entry1,
-					      struct stage_data *src_entry2)
+					      const char *branch2)
 {
-	int ostage1 = 0, ostage2;
 	struct rename_conflict_info *ci;
 
 	/*
@@ -269,8 +264,7 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
 		setup_rename_conflict_info(rename_type,
 					   opt,
 					   ren2,       ren1,
-					   branch2,    branch1,
-					   src_entry2, src_entry1);
+					   branch2,    branch1);
 		return;
 	}
 
@@ -287,28 +281,6 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
 	if (ren2) {
 		ci->ren2->dst_entry->rename_conflict_info = ci;
 	}
-
-	/*
-	 * For each rename, there could have been
-	 * modifications on the side of history where that
-	 * file was not renamed.
-	 */
-	if (rename_type == RENAME_ADD ||
-	    rename_type == RENAME_TWO_FILES_TO_ONE) {
-		ostage1 = opt->branch1 == branch1 ? 3 : 2;
-
-		ci->ren1_other.path = ren1->pair->one->path;
-		oidcpy(&ci->ren1_other.oid, &src_entry1->stages[ostage1].oid);
-		ci->ren1_other.mode = src_entry1->stages[ostage1].mode;
-	}
-
-	if (rename_type == RENAME_TWO_FILES_TO_ONE) {
-		ostage2 = ostage1 ^ 1;
-
-		ci->ren2_other.path = ren2->pair->one->path;
-		oidcpy(&ci->ren2_other.oid, &src_entry2->stages[ostage2].oid);
-		ci->ren2_other.mode = src_entry2->stages[ostage2].mode;
-	}
 }
 
 static int show(struct merge_options *opt, int v)
@@ -1688,6 +1660,7 @@ static int handle_rename_add(struct merge_options *opt,
 	/* a was renamed to c, and a separate c was added. */
 	struct diff_filespec *a = ci->ren1->pair->one;
 	struct diff_filespec *c = ci->ren1->pair->two;
+	struct diff_filespec tmp;
 	char *path = c->path;
 	char *prev_path_desc;
 	struct merge_file_info mfi;
@@ -1699,8 +1672,12 @@ static int handle_rename_add(struct merge_options *opt,
 	       a->path, c->path, ci->branch1,
 	       c->path, ci->branch2);
 
+	filespec_from_entry(&tmp, ci->ren1->src_entry, other_stage);
+	tmp.path = a->path;
+
 	prev_path_desc = xstrfmt("version of %s from %s", path, a->path);
-	if (merge_mode_and_contents(opt, a, c, &ci->ren1_other, prev_path_desc,
+	if (merge_mode_and_contents(opt, a, c, &tmp,
+				    prev_path_desc,
 				    opt->branch1, opt->branch2,
 				    1 + opt->call_depth * 2, &mfi))
 		return -1;
@@ -1850,6 +1827,7 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
 	struct diff_filespec *b = ci->ren2->pair->one;
 	struct diff_filespec *c1 = ci->ren1->pair->two;
 	struct diff_filespec *c2 = ci->ren2->pair->two;
+	struct diff_filespec tmp1, tmp2;
 	char *path = c1->path; /* == c2->path */
 	char *path_side_1_desc;
 	char *path_side_2_desc;
@@ -1862,12 +1840,17 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
 	       a->path, c1->path, ci->branch1,
 	       b->path, c2->path, ci->branch2);
 
+	filespec_from_entry(&tmp1, ci->ren1->src_entry, 3);
+	tmp1.path = a->path;
+	filespec_from_entry(&tmp2, ci->ren2->src_entry, 2);
+	tmp2.path = b->path;
+
 	path_side_1_desc = xstrfmt("version of %s from %s", path, a->path);
 	path_side_2_desc = xstrfmt("version of %s from %s", path, b->path);
-	if (merge_mode_and_contents(opt, a, c1, &ci->ren1_other, path_side_1_desc,
+	if (merge_mode_and_contents(opt, a, c1, &tmp1, path_side_1_desc,
 				    opt->branch1, opt->branch2,
 				    1 + opt->call_depth * 2, &mfi_c1) ||
-	    merge_mode_and_contents(opt, b, &ci->ren2_other, c2, path_side_2_desc,
+	    merge_mode_and_contents(opt, b, &tmp2, c2, path_side_2_desc,
 				    opt->branch1, opt->branch2,
 				    1 + opt->call_depth * 2, &mfi_c2))
 		return -1;
@@ -2728,9 +2711,7 @@ static int process_renames(struct merge_options *opt,
 						   ren1,
 						   ren2,
 						   branch1,
-						   branch2,
-						   NULL,
-						   NULL);
+						   branch2);
 		} else if ((lookup = string_list_lookup(renames2Dst, ren1_dst))) {
 			/* Two different files renamed to the same thing */
 			char *ren2_dst;
@@ -2753,9 +2734,7 @@ static int process_renames(struct merge_options *opt,
 						   ren1,
 						   ren2,
 						   branch1,
-						   branch2,
-						   ren1->src_entry,
-						   ren2->src_entry);
+						   branch2);
 
 		} else {
 			/* Renamed in 1, maybe changed in 2 */
@@ -2794,18 +2773,14 @@ static int process_renames(struct merge_options *opt,
 							   ren1,
 							   NULL,
 							   branch1,
-							   branch2,
-							   NULL,
-							   NULL);
+							   branch2);
 			} else if (oid_eq(&src_other.oid, &null_oid)) {
 				setup_rename_conflict_info(RENAME_DELETE,
 							   opt,
 							   ren1,
 							   NULL,
 							   branch1,
-							   branch2,
-							   NULL,
-							   NULL);
+							   branch2);
 			} else if ((dst_other.mode == ren1->pair->two->mode) &&
 				   oid_eq(&dst_other.oid, &ren1->pair->two->oid)) {
 				/*
@@ -2836,9 +2811,7 @@ static int process_renames(struct merge_options *opt,
 							   ren1,
 							   NULL,
 							   branch1,
-							   branch2,
-							   ren1->src_entry,
-							   NULL);
+							   branch2);
 			} else
 				try_merge = 1;
 
@@ -2862,8 +2835,6 @@ static int process_renames(struct merge_options *opt,
 							   ren1,
 							   NULL,
 							   branch1,
-							   NULL,
-							   NULL,
 							   NULL);
 			}
 		}
-- 
2.21.0.211.g078f4bef79.dirty


  parent reply	other threads:[~2019-03-30  0:34 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27 12:47 [BUG] All files in folder are moved when cherry-picking commit that moves fewer files Linus Nilsson
2019-02-27 14:30 ` Phillip Wood
2019-02-27 16:02   ` Elijah Newren
2019-02-27 16:40     ` Jeff King
2019-02-27 17:31       ` Elijah Newren
2019-02-28  8:16         ` Linus Nilsson
2019-03-01  2:52         ` Junio C Hamano
2019-03-02 23:48           ` Elijah Newren
2019-03-03  1:33             ` Junio C Hamano
2019-03-06  0:27               ` Elijah Newren
2019-03-06  4:43                 ` Junio C Hamano
2019-03-07  4:14                   ` Elijah Newren
2019-03-07  5:45                     ` Junio C Hamano
2019-03-07  5:45                     ` Junio C Hamano
2019-03-30  0:33                 ` [PATCH v2 00/15] Switch directory rename detection default Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 01/15] Use 'unsigned short' for mode, like diff_filespec does Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 02/15] merge-recursive: rename merge_options argument from 'o' to 'opt' Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 03/15] merge-recursive: rename diff_filespec 'one' to 'o' Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 04/15] merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf' Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 05/15] merge-recursive: use 'ci' for rename_conflict_info variable name Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 06/15] merge-recursive: move some struct declarations together Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 07/15] merge-recursive: shrink rename_conflict_info Elijah Newren
2019-03-30  0:33                   ` Elijah Newren [this message]
2019-03-30  0:33                   ` [PATCH v2 09/15] merge-recursive: track branch where rename occurred in rename struct Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 10/15] merge-recursive: cleanup handle_rename_* function signatures Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 11/15] merge-recursive: switch from (oid,mode) pairs to a diff_filespec Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 12/15] t6043: fix copied test description to match its purpose Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 13/15] merge-recursive: track information associated with directory renames Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 14/15] merge-recursive: give callers of handle_content_merge() access to contents Elijah Newren
2019-03-30  0:33                   ` [PATCH v2 15/15] merge-recursive: switch directory rename detection default Elijah Newren
2019-03-30  9:12                     ` Ævar Arnfjörð Bjarmason
2019-04-01 15:41                       ` Elijah Newren
2019-04-05 15:00                   ` [PATCH v3 00/15] Switch " Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 01/15] Use 'unsigned short' for mode, like diff_filespec does Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 02/15] merge-recursive: rename merge_options argument from 'o' to 'opt' Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 03/15] merge-recursive: rename diff_filespec 'one' to 'o' Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 04/15] merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf' Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 05/15] merge-recursive: use 'ci' for rename_conflict_info variable name Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 06/15] merge-recursive: move some struct declarations together Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 07/15] merge-recursive: shrink rename_conflict_info Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 08/15] merge-recursive: remove ren[12]_other fields from rename_conflict_info Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 09/15] merge-recursive: track branch where rename occurred in rename struct Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 10/15] merge-recursive: cleanup handle_rename_* function signatures Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 11/15] merge-recursive: switch from (oid,mode) pairs to a diff_filespec Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 12/15] t6043: fix copied test description to match its purpose Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 13/15] merge-recursive: track information associated with directory renames Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 14/15] merge-recursive: give callers of handle_content_merge() access to contents Elijah Newren
2019-04-05 15:00                     ` [PATCH v3 15/15] merge-recursive: switch directory rename detection default Elijah Newren
2019-04-05 16:32                     ` [PATCH v3 00/15] Switch " Jacob Keller

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=20190330003336.21940-9-newren@gmail.com \
    --to=newren@gmail.com \
    --cc=Linus.Nilsson@trimma.se \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=phillip.wood@dunelm.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.