Skip to content

Commit 3f9c92e

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9cd1b5 commit 3f9c92e

File tree

1 file changed

+21
-50
lines changed

1 file changed

+21
-50
lines changed

merge-recursive.c

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,15 @@ struct rename_conflict_info {
242242
struct rename *ren2;
243243
const char *branch1;
244244
const char *branch2;
245-
struct diff_filespec ren1_other;
246-
struct diff_filespec ren2_other;
247245
};
248246

249247
static inline void setup_rename_conflict_info(enum rename_type rename_type,
250248
struct merge_options *opt,
251249
struct rename *ren1,
252250
struct rename *ren2,
253251
const char *branch1,
254-
const char *branch2,
255-
struct stage_data *src_entry1,
256-
struct stage_data *src_entry2)
252+
const char *branch2)
257253
{
258-
int ostage1 = 0, ostage2;
259254
struct rename_conflict_info *ci;
260255

261256
/*
@@ -269,8 +264,7 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
269264
setup_rename_conflict_info(rename_type,
270265
opt,
271266
ren2, ren1,
272-
branch2, branch1,
273-
src_entry2, src_entry1);
267+
branch2, branch1);
274268
return;
275269
}
276270

@@ -287,28 +281,6 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
287281
if (ren2) {
288282
ci->ren2->dst_entry->rename_conflict_info = ci;
289283
}
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-
}
312284
}
313285

314286
static int show(struct merge_options *opt, int v)
@@ -1688,6 +1660,7 @@ static int handle_rename_add(struct merge_options *opt,
16881660
/* a was renamed to c, and a separate c was added. */
16891661
struct diff_filespec *a = ci->ren1->pair->one;
16901662
struct diff_filespec *c = ci->ren1->pair->two;
1663+
struct diff_filespec tmp;
16911664
char *path = c->path;
16921665
char *prev_path_desc;
16931666
struct merge_file_info mfi;
@@ -1699,8 +1672,12 @@ static int handle_rename_add(struct merge_options *opt,
16991672
a->path, c->path, ci->branch1,
17001673
c->path, ci->branch2);
17011674

1675+
filespec_from_entry(&tmp, ci->ren1->src_entry, other_stage);
1676+
tmp.path = a->path;
1677+
17021678
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,
17041681
opt->branch1, opt->branch2,
17051682
1 + opt->call_depth * 2, &mfi))
17061683
return -1;
@@ -1850,6 +1827,7 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
18501827
struct diff_filespec *b = ci->ren2->pair->one;
18511828
struct diff_filespec *c1 = ci->ren1->pair->two;
18521829
struct diff_filespec *c2 = ci->ren2->pair->two;
1830+
struct diff_filespec tmp1, tmp2;
18531831
char *path = c1->path; /* == c2->path */
18541832
char *path_side_1_desc;
18551833
char *path_side_2_desc;
@@ -1862,12 +1840,17 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
18621840
a->path, c1->path, ci->branch1,
18631841
b->path, c2->path, ci->branch2);
18641842

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+
18651848
path_side_1_desc = xstrfmt("version of %s from %s", path, a->path);
18661849
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,
18681851
opt->branch1, opt->branch2,
18691852
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,
18711854
opt->branch1, opt->branch2,
18721855
1 + opt->call_depth * 2, &mfi_c2))
18731856
return -1;
@@ -2728,9 +2711,7 @@ static int process_renames(struct merge_options *opt,
27282711
ren1,
27292712
ren2,
27302713
branch1,
2731-
branch2,
2732-
NULL,
2733-
NULL);
2714+
branch2);
27342715
} else if ((lookup = string_list_lookup(renames2Dst, ren1_dst))) {
27352716
/* Two different files renamed to the same thing */
27362717
char *ren2_dst;
@@ -2753,9 +2734,7 @@ static int process_renames(struct merge_options *opt,
27532734
ren1,
27542735
ren2,
27552736
branch1,
2756-
branch2,
2757-
ren1->src_entry,
2758-
ren2->src_entry);
2737+
branch2);
27592738

27602739
} else {
27612740
/* Renamed in 1, maybe changed in 2 */
@@ -2794,18 +2773,14 @@ static int process_renames(struct merge_options *opt,
27942773
ren1,
27952774
NULL,
27962775
branch1,
2797-
branch2,
2798-
NULL,
2799-
NULL);
2776+
branch2);
28002777
} else if (oid_eq(&src_other.oid, &null_oid)) {
28012778
setup_rename_conflict_info(RENAME_DELETE,
28022779
opt,
28032780
ren1,
28042781
NULL,
28052782
branch1,
2806-
branch2,
2807-
NULL,
2808-
NULL);
2783+
branch2);
28092784
} else if ((dst_other.mode == ren1->pair->two->mode) &&
28102785
oid_eq(&dst_other.oid, &ren1->pair->two->oid)) {
28112786
/*
@@ -2836,9 +2811,7 @@ static int process_renames(struct merge_options *opt,
28362811
ren1,
28372812
NULL,
28382813
branch1,
2839-
branch2,
2840-
ren1->src_entry,
2841-
NULL);
2814+
branch2);
28422815
} else
28432816
try_merge = 1;
28442817

@@ -2862,8 +2835,6 @@ static int process_renames(struct merge_options *opt,
28622835
ren1,
28632836
NULL,
28642837
branch1,
2865-
NULL,
2866-
NULL,
28672838
NULL);
28682839
}
28692840
}

0 commit comments

Comments
 (0)