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>
Alex Riesen committed
Apr 25, 2007 at 22:06 UTC
c135ee88f8584996ead993c76015d2c03798ab9e
1 file changed
+19
-13
merge-recursive.c
+19
-13
@@ -1342,20 +1342,26 @@ static int process_renames(struct path_list *a_renames,
1342
mfi = merge_file(o, a, b,
1343
a_branch, b_branch);
1344
1345
- if (mfi.merge || !mfi.clean)
1346
- output(1, "Renamed %s => %s", ren1_src, ren1_dst);
1347
- if (mfi.merge)
1348
- output(2, "Auto-merged %s", ren1_dst);
1349
- if (!mfi.clean) {
1350
- output(1, "CONFLICT (rename/modify): Merge conflict in %s",
1351
- ren1_dst);
1352
- clean_merge = 0;
1353
-
1354
- if (!index_only)
1355
- update_stages(ren1_dst,
1356
- o, a, b, 1);
1345
+ if (mfi.merge && mfi.clean &&
1346
+ sha_eq(mfi.sha, ren1->pair->two->sha1) &&
1347
+ mfi.mode == ren1->pair->two->mode)
1348
+ output(3, "Skipped %s (merged same as existing)", ren1_dst);
1349
+ else {
1350
+ if (mfi.merge || !mfi.clean)
1351
+ output(1, "Renamed %s => %s", ren1_src, ren1_dst);
1352
+ if (mfi.merge)
1353
+ output(2, "Auto-merged %s", ren1_dst);
1354
+ if (!mfi.clean) {
1355
+ output(1, "CONFLICT (rename/modify): Merge conflict in %s",
1356
+ ren1_dst);
1357
+ clean_merge = 0;
1358
+
1359
+ if (!index_only)
1360
+ update_stages(ren1_dst,
1361
+ o, a, b, 1);
1362
+ }
1363
+ update_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);
1364
}
1358
- update_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);
1365
}
1366
}
1367
}