merge-recursive: remove ren[12]_other fields from rename_conflict_info

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Apr 5, 2019 at 08:00 UTC 3f9c92ec99222515c6ebac1dc12d0bc3a6d4ae08
1 file changed +21 -50
merge-recursive.c
+21 -50
@@ -242,8 +242,6 @@ struct rename_conflict_info {
242 struct rename *ren2;
243 const char *branch1;
244 const char *branch2;
245 - struct diff_filespec ren1_other;
246 - struct diff_filespec ren2_other;
245 };
246
247 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,
249 struct rename *ren1,
250 struct rename *ren2,
251 const char *branch1,
254 - const char *branch2,
255 - struct stage_data *src_entry1,
256 - struct stage_data *src_entry2)
252 + const char *branch2)
253 {
258 - int ostage1 = 0, ostage2;
254 struct rename_conflict_info *ci;
255
256 /*
@@ -269,8 +264,7 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
264 setup_rename_conflict_info(rename_type,
265 opt,
266 ren2, ren1,
272 - branch2, branch1,
273 - src_entry2, src_entry1);
267 + branch2, branch1);
268 return;
269 }
270
@@ -287,28 +281,6 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
281 if (ren2) {
282 ci->ren2->dst_entry->rename_conflict_info = ci;
283 }
290 -
291 - /*
292 - * For each rename, there could have been
293 - * modifications on the side of history where that
294 - * file was not renamed.
295 - */
296 - if (rename_type == RENAME_ADD ||
297 - rename_type == RENAME_TWO_FILES_TO_ONE) {
298 - ostage1 = opt->branch1 == branch1 ? 3 : 2;
299 -
300 - ci->ren1_other.path = ren1->pair->one->path;
301 - oidcpy(&ci->ren1_other.oid, &src_entry1->stages[ostage1].oid);
302 - ci->ren1_other.mode = src_entry1->stages[ostage1].mode;
303 - }
304 -
305 - if (rename_type == RENAME_TWO_FILES_TO_ONE) {
306 - ostage2 = ostage1 ^ 1;
307 -
308 - ci->ren2_other.path = ren2->pair->one->path;
309 - oidcpy(&ci->ren2_other.oid, &src_entry2->stages[ostage2].oid);
310 - ci->ren2_other.mode = src_entry2->stages[ostage2].mode;
311 - }
284 }
285
286 static int show(struct merge_options *opt, int v)
@@ -1688,6 +1660,7 @@ static int handle_rename_add(struct merge_options *opt,
1660 /* a was renamed to c, and a separate c was added. */
1661 struct diff_filespec *a = ci->ren1->pair->one;
1662 struct diff_filespec *c = ci->ren1->pair->two;
1663 + struct diff_filespec tmp;
1664 char *path = c->path;
1665 char *prev_path_desc;
1666 struct merge_file_info mfi;
@@ -1699,8 +1672,12 @@ static int handle_rename_add(struct merge_options *opt,
1672 a->path, c->path, ci->branch1,
1673 c->path, ci->branch2);
1674
1675 + filespec_from_entry(&tmp, ci->ren1->src_entry, other_stage);
1676 + tmp.path = a->path;
1677 +
1678 prev_path_desc = xstrfmt("version of %s from %s", path, a->path);
1703 - if (merge_mode_and_contents(opt, a, c, &ci->ren1_other, prev_path_desc,
1679 + if (merge_mode_and_contents(opt, a, c, &tmp,
1680 + prev_path_desc,
1681 opt->branch1, opt->branch2,
1682 1 + opt->call_depth * 2, &mfi))
1683 return -1;
@@ -1850,6 +1827,7 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
1827 struct diff_filespec *b = ci->ren2->pair->one;
1828 struct diff_filespec *c1 = ci->ren1->pair->two;
1829 struct diff_filespec *c2 = ci->ren2->pair->two;
1830 + struct diff_filespec tmp1, tmp2;
1831 char *path = c1->path; /* == c2->path */
1832 char *path_side_1_desc;
1833 char *path_side_2_desc;
@@ -1862,12 +1840,17 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
1840 a->path, c1->path, ci->branch1,
1841 b->path, c2->path, ci->branch2);
1842
1843 + filespec_from_entry(&tmp1, ci->ren1->src_entry, 3);
1844 + tmp1.path = a->path;
1845 + filespec_from_entry(&tmp2, ci->ren2->src_entry, 2);
1846 + tmp2.path = b->path;
1847 +
1848 path_side_1_desc = xstrfmt("version of %s from %s", path, a->path);
1849 path_side_2_desc = xstrfmt("version of %s from %s", path, b->path);
1867 - if (merge_mode_and_contents(opt, a, c1, &ci->ren1_other, path_side_1_desc,
1850 + if (merge_mode_and_contents(opt, a, c1, &tmp1, path_side_1_desc,
1851 opt->branch1, opt->branch2,
1852 1 + opt->call_depth * 2, &mfi_c1) ||
1870 - merge_mode_and_contents(opt, b, &ci->ren2_other, c2, path_side_2_desc,
1853 + merge_mode_and_contents(opt, b, &tmp2, c2, path_side_2_desc,
1854 opt->branch1, opt->branch2,
1855 1 + opt->call_depth * 2, &mfi_c2))
1856 return -1;
@@ -2728,9 +2711,7 @@ static int process_renames(struct merge_options *opt,
2711 ren1,
2712 ren2,
2713 branch1,
2731 - branch2,
2732 - NULL,
2733 - NULL);
2714 + branch2);
2715 } else if ((lookup = string_list_lookup(renames2Dst, ren1_dst))) {
2716 /* Two different files renamed to the same thing */
2717 char *ren2_dst;
@@ -2753,9 +2734,7 @@ static int process_renames(struct merge_options *opt,
2734 ren1,
2735 ren2,
2736 branch1,
2756 - branch2,
2757 - ren1->src_entry,
2758 - ren2->src_entry);
2737 + branch2);
2738
2739 } else {
2740 /* Renamed in 1, maybe changed in 2 */
@@ -2794,18 +2773,14 @@ static int process_renames(struct merge_options *opt,
2773 ren1,
2774 NULL,
2775 branch1,
2797 - branch2,
2798 - NULL,
2799 - NULL);
2776 + branch2);
2777 } else if (oid_eq(&src_other.oid, &null_oid)) {
2778 setup_rename_conflict_info(RENAME_DELETE,
2779 opt,
2780 ren1,
2781 NULL,
2782 branch1,
2806 - branch2,
2807 - NULL,
2808 - NULL);
2783 + branch2);
2784 } else if ((dst_other.mode == ren1->pair->two->mode) &&
2785 oid_eq(&dst_other.oid, &ren1->pair->two->oid)) {
2786 /*
@@ -2836,9 +2811,7 @@ static int process_renames(struct merge_options *opt,
2811 ren1,
2812 NULL,
2813 branch1,
2839 - branch2,
2840 - ren1->src_entry,
2841 - NULL);
2814 + branch2);
2815 } else
2816 try_merge = 1;
2817
@@ -2862,8 +2835,6 @@ static int process_renames(struct merge_options *opt,
2835 ren1,
2836 NULL,
2837 branch1,
2865 - NULL,
2866 - NULL,
2838 NULL);
2839 }
2840 }