Avoid excessive rewrites in merge-recursive

If a file is changed in one branch, and renamed and changed to the
same content in another branch than we can skip the rewrite of this
file in the working directory, as the content does not change.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Alex Riesen 2007-04-25 22:06:59 +02:00 committed by Junio C Hamano
parent 6169a89c4f
commit c135ee88f8

View File

@ -1342,20 +1342,26 @@ static int process_renames(struct path_list *a_renames,
mfi = merge_file(o, a, b, mfi = merge_file(o, a, b,
a_branch, b_branch); a_branch, b_branch);
if (mfi.merge || !mfi.clean) if (mfi.merge && mfi.clean &&
output(1, "Renamed %s => %s", ren1_src, ren1_dst); sha_eq(mfi.sha, ren1->pair->two->sha1) &&
if (mfi.merge) mfi.mode == ren1->pair->two->mode)
output(2, "Auto-merged %s", ren1_dst); output(3, "Skipped %s (merged same as existing)", ren1_dst);
if (!mfi.clean) { else {
output(1, "CONFLICT (rename/modify): Merge conflict in %s", if (mfi.merge || !mfi.clean)
ren1_dst); output(1, "Renamed %s => %s", ren1_src, ren1_dst);
clean_merge = 0; if (mfi.merge)
output(2, "Auto-merged %s", ren1_dst);
if (!mfi.clean) {
output(1, "CONFLICT (rename/modify): Merge conflict in %s",
ren1_dst);
clean_merge = 0;
if (!index_only) if (!index_only)
update_stages(ren1_dst, update_stages(ren1_dst,
o, a, b, 1); o, a, b, 1);
}
update_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);
} }
update_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);
} }
} }
} }