mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
merge-recursive: Move handling of double rename of one file to two
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2a669c341a
commit
07413c5a31
@ -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);
|
* update_file(o, 0, pair2->two->sha1, pair2->two->mode, dst_name2);
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
update_stages(dst_name1, NULL, pair1->two, NULL, 1);
|
update_stages(ren1_dst, NULL, pair1->two, NULL, 1);
|
||||||
update_stages(dst_name2, NULL, NULL, pair2->two, 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--)
|
while (delp--)
|
||||||
free(del[delp]);
|
free(del[delp]);
|
||||||
@ -958,19 +961,15 @@ static int process_renames(struct merge_options *o,
|
|||||||
ren2->dst_entry->processed = 1;
|
ren2->dst_entry->processed = 1;
|
||||||
ren2->processed = 1;
|
ren2->processed = 1;
|
||||||
if (strcmp(ren1_dst, ren2_dst) != 0) {
|
if (strcmp(ren1_dst, ren2_dst) != 0) {
|
||||||
clean_merge = 0;
|
setup_rename_df_conflict_info(RENAME_ONE_FILE_TO_TWO,
|
||||||
output(o, 1, "CONFLICT (rename/rename): "
|
ren1->pair,
|
||||||
"Rename \"%s\"->\"%s\" in branch \"%s\" "
|
ren2->pair,
|
||||||
"rename \"%s\"->\"%s\" in \"%s\"%s",
|
branch1,
|
||||||
src, ren1_dst, branch1,
|
branch2,
|
||||||
src, ren2_dst, branch2,
|
ren1->dst_entry,
|
||||||
o->call_depth ? " (left unresolved)": "");
|
ren2->dst_entry);
|
||||||
if (o->call_depth) {
|
remove_file(o, 0, ren1_dst, 0);
|
||||||
remove_file_from_cache(src);
|
/* ren2_dst not in head, so no need to delete */
|
||||||
update_file(o, 0, ren1->pair->one->sha1,
|
|
||||||
ren1->pair->one->mode, src);
|
|
||||||
}
|
|
||||||
conflict_rename_rename_1to2(o, ren1->pair, branch1, ren2->pair, branch2);
|
|
||||||
} else {
|
} else {
|
||||||
struct merge_file_info mfi;
|
struct merge_file_info mfi;
|
||||||
remove_file(o, 1, ren1_src, 1);
|
remove_file(o, 1, ren1_src, 1);
|
||||||
@ -1364,7 +1363,33 @@ static int process_df_entry(struct merge_options *o,
|
|||||||
|
|
||||||
entry->processed = 1;
|
entry->processed = 1;
|
||||||
if (entry->rename_df_conflict_info) {
|
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) {
|
} else if (!o_sha && !!a_sha != !!b_sha) {
|
||||||
/* directory -> (directory, file) */
|
/* directory -> (directory, file) */
|
||||||
const char *add_branch;
|
const char *add_branch;
|
||||||
|
@ -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"
|
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 &&
|
git checkout -q first-rename^0 &&
|
||||||
test_must_fail git merge --strategy=recursive second-rename &&
|
test_must_fail git merge --strategy=recursive second-rename &&
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user