git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Avoid excessive rewrites in merge-recursive

From
Alex Riesen <raa.lkml@gmail.com>
Date
Apr 25, 2007, 20:06 UTC
Message-ID
<20070425200659.GA30061@steel.home>

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>
---

Just as you may have thought merge-recursive cannot get any uglier someone comes and does just this: puts another level of indentation.

It is a nice speed up, though. Besides, I had some directories moved between branches, and the rewrites caused a rebuild of hefty 8000 objects, which in windows terms is around 2 hours.

 merge-recursive.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 403a4c8..37f1ba9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1342,20 +1342,26 @@ static int process_renames(struct path_list *a_renames,
 				mfi = merge_file(o, a, b,
 						a_branch, b_branch);
 
-				if (mfi.merge || !mfi.clean)
-					output(1, "Renamed %s => %s", ren1_src, ren1_dst);
-				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)
-						update_stages(ren1_dst,
-								o, a, b, 1);
+				if (mfi.merge && mfi.clean &&
+				    sha_eq(mfi.sha, ren1->pair->two->sha1) &&
+				    mfi.mode == ren1->pair->two->mode)
+					output(3, "Skipped %s (merged same as existing)", ren1_dst);
+				else {
+					if (mfi.merge || !mfi.clean)
+						output(1, "Renamed %s => %s", ren1_src, ren1_dst);
+					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)
+							update_stages(ren1_dst,
+								      o, a, b, 1);
+					}
+					update_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);
 				}
-				update_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);
 			}
 		}
 	}
-- 
1.5.2.rc0.63.gdfc8-dirty
Next: Junio C Hamano
Message 1 of 4 in “Avoid excessive rewrites in merge-recursive”
  1. Avoid excessive rewrites in merge-recursiveAlex Riesen, Apr 25, 2007
  2. Junio C HamanoApr 25, 2007
  3. Alex RiesenApr 25, 2007
  4. Ignore merged status of the file-level mergeAlex Riesen, Apr 26, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.