{"thread":{"id":"7845","subject":"[PATCH] Avoid excessive rewrites in merge-recursive","startedAt":"2007-04-25T20:06:59Z","lastAt":"2007-04-26T19:13:49Z","messageCount":4,"participants":["Alex Riesen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40435","messageId":"20070425200659.GA30061@steel.home","threadId":"7845","inReplyTo":null,"subject":"[PATCH] Avoid excessive rewrites in merge-recursive","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-25T20:06:59Z","receivedAt":"2007-04-25T20:06:59Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"If a file is changed in one branch, and renamed and changed to the\nsame content in another branch than we can skip the rewrite of this\nfile in the working directory, as the content does not change.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nJust as you may have thought merge-recursive cannot get any uglier\nsomeone comes and does just this: puts another level of indentation.\n\nIt is a nice speed up, though. Besides, I had some directories moved\nbetween branches, and the rewrites caused a rebuild of hefty 8000\nobjects, which in windows terms is around 2 hours.\n\n merge-recursive.c |   32 +++++++++++++++++++-------------\n 1 files changed, 19 insertions(+), 13 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 403a4c8..37f1ba9 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1342,20 +1342,26 @@ static int process_renames(struct path_list *a_renames,\n \t\t\t\tmfi = merge_file(o, a, b,\n \t\t\t\t\t\ta_branch, b_branch);\n \n-\t\t\t\tif (mfi.merge || !mfi.clean)\n-\t\t\t\t\toutput(1, \"Renamed %s => %s\", ren1_src, ren1_dst);\n-\t\t\t\tif (mfi.merge)\n-\t\t\t\t\toutput(2, \"Auto-merged %s\", ren1_dst);\n-\t\t\t\tif (!mfi.clean) {\n-\t\t\t\t\toutput(1, \"CONFLICT (rename/modify): Merge conflict in %s\",\n-\t\t\t\t\t       ren1_dst);\n-\t\t\t\t\tclean_merge = 0;\n-\n-\t\t\t\t\tif (!index_only)\n-\t\t\t\t\t\tupdate_stages(ren1_dst,\n-\t\t\t\t\t\t\t\to, a, b, 1);\n+\t\t\t\tif (mfi.merge && mfi.clean &&\n+\t\t\t\t    sha_eq(mfi.sha, ren1->pair->two->sha1) &&\n+\t\t\t\t    mfi.mode == ren1->pair->two->mode)\n+\t\t\t\t\toutput(3, \"Skipped %s (merged same as existing)\", ren1_dst);\n+\t\t\t\telse {\n+\t\t\t\t\tif (mfi.merge || !mfi.clean)\n+\t\t\t\t\t\toutput(1, \"Renamed %s => %s\", ren1_src, ren1_dst);\n+\t\t\t\t\tif (mfi.merge)\n+\t\t\t\t\t\toutput(2, \"Auto-merged %s\", ren1_dst);\n+\t\t\t\t\tif (!mfi.clean) {\n+\t\t\t\t\t\toutput(1, \"CONFLICT (rename/modify): Merge conflict in %s\",\n+\t\t\t\t\t\t       ren1_dst);\n+\t\t\t\t\t\tclean_merge = 0;\n+\n+\t\t\t\t\t\tif (!index_only)\n+\t\t\t\t\t\t\tupdate_stages(ren1_dst,\n+\t\t\t\t\t\t\t\t      o, a, b, 1);\n+\t\t\t\t\t}\n+\t\t\t\t\tupdate_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);\n \t\t\t\t}\n-\t\t\t\tupdate_file(mfi.clean, mfi.sha, mfi.mode, ren1_dst);\n \t\t\t}\n \t\t}\n \t}\n-- \n1.5.2.rc0.63.gdfc8-dirty\n"},{"id":"40459","messageId":"7vodlcup9e.fsf@assigned-by-dhcp.cox.net","threadId":"7845","inReplyTo":"20070425200659.GA30061@steel.home","subject":"Re: [PATCH] Avoid excessive rewrites in merge-recursive","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-25T21:18:21Z","receivedAt":"2007-04-25T21:18:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alex Riesen <raa.lkml@gmail.com> writes:\n\n> Just as you may have thought merge-recursive cannot get any uglier\n> someone comes and does just this: puts another level of indentation.\n\nIt really was painful for me the last time I touched the file,\nso I share that feeling.  The complexity of this program is\ngetting out of hand.\n\nProbably we would want a refactoring before doing something like\nthis.\n"},{"id":"40463","messageId":"20070425221341.GH30061@steel.home","threadId":"7845","inReplyTo":"7vodlcup9e.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Avoid excessive rewrites in merge-recursive","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-25T22:13:41Z","receivedAt":"2007-04-25T22:13:41Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Wed, Apr 25, 2007 23:18:21 +0200:\n> \n> > Just as you may have thought merge-recursive cannot get any uglier\n> > someone comes and does just this: puts another level of indentation.\n> \n> It really was painful for me the last time I touched the file,\n> so I share that feeling.  The complexity of this program is\n> getting out of hand.\n> \n> Probably we would want a refactoring before doing something like\n> this.\n> \n\nI want. I just can't afford something like this lately.\nI'm even saving on \"am\"s and \"not\"s! :)\n"},{"id":"40519","messageId":"20070426191349.GA9964@steel.home","threadId":"7845","inReplyTo":"20070425200659.GA30061@steel.home","subject":"[PATCH] Ignore merged status of the file-level merge","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-26T19:13:49Z","receivedAt":"2007-04-26T19:13:49Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"as it is not relevant for whether the result should be written.\nEven if no real merge happened, there might be _no_ reason to\nrewrite the working tree file. Maybe even more so.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\n merge-recursive.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 094ac59..8f72b2c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1342,7 +1342,7 @@ static int process_renames(struct path_list *a_renames,\n \t\t\t\tmfi = merge_file(o, a, b,\n \t\t\t\t\t\ta_branch, b_branch);\n \n-\t\t\t\tif (mfi.merge && mfi.clean &&\n+\t\t\t\tif (mfi.clean &&\n \t\t\t\t    sha_eq(mfi.sha, ren1->pair->two->sha1) &&\n \t\t\t\t    mfi.mode == ren1->pair->two->mode)\n \t\t\t\t\t/*\n-- \n1.5.2.rc0.65.g92b0b\n"}]}