{"thread":{"id":"25033","subject":"[PATCH] merge-recursive: Small code cleanup","startedAt":"2010-09-08T07:21:22Z","lastAt":"2010-09-08T07:21:22Z","messageCount":1,"participants":["Elijah Newren"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"150283","messageId":"1283930482-10228-1-git-send-email-newren@gmail.com","threadId":"25033","inReplyTo":null,"subject":"[PATCH] merge-recursive: Small code cleanup","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2010-09-08T07:21:22Z","receivedAt":"2010-09-08T07:21:22Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"process_renames() had a variable named \"stage\" and derived variables\nsrc_other and dst_other whose purpose was not entirely clear to me.  Make\nthe name of stage slightly more descriptive and add a brief comment\nexplaining what is occurring.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\nWas previously PATCH 2/3 from my \"fix resolvable rename + D/F conflict\ntestcases\" series, but I've pulled this patch out since it's not\nstrictly related.  Also, due to Ken Schalk's response, I've dropped\nthe piece of the patch he pointed out an issue in.  So now it's just a\nsmaller cleanup, that is now based on maint.\n\n merge-recursive.c |   20 ++++++++++++++------\n 1 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex fb6aa4a..ba9cbab 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -924,15 +924,23 @@ static int process_renames(struct merge_options *o,\n \t\t\tstruct string_list_item *item;\n \t\t\t/* we only use sha1 and mode of these */\n \t\t\tstruct diff_filespec src_other, dst_other;\n-\t\t\tint try_merge, stage = a_renames == renames1 ? 3: 2;\n+\t\t\tint try_merge;\n \n-\t\t\tremove_file(o, 1, ren1_src, o->call_depth || stage == 3);\n+\t\t\t/*\n+\t\t\t * unpack_trees loads entries from common-commit\n+\t\t\t * into stage 1, from head-commit into stage 2, and\n+\t\t\t * from merge-commit into stage 3.  We keep track\n+\t\t\t * of which side corresponds to the rename.\n+\t\t\t */\n+\t\t\tint renamed_stage = a_renames == renames1 ? 2 : 3;\n+\t\t\tint other_stage =   a_renames == renames1 ? 3 : 2;\n \n-\t\t\thashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);\n-\t\t\tsrc_other.mode = ren1->src_entry->stages[stage].mode;\n-\t\t\thashcpy(dst_other.sha1, ren1->dst_entry->stages[stage].sha);\n-\t\t\tdst_other.mode = ren1->dst_entry->stages[stage].mode;\n+\t\t\tremove_file(o, 1, ren1_src, o->call_depth || renamed_stage == 2);\n \n+\t\t\thashcpy(src_other.sha1, ren1->src_entry->stages[other_stage].sha);\n+\t\t\tsrc_other.mode = ren1->src_entry->stages[other_stage].mode;\n+\t\t\thashcpy(dst_other.sha1, ren1->dst_entry->stages[other_stage].sha);\n+\t\t\tdst_other.mode = ren1->dst_entry->stages[other_stage].mode;\n \t\t\ttry_merge = 0;\n \n \t\t\tif (string_list_has_string(&o->current_directory_set, ren1_dst)) {\n-- \n1.7.2.3.7.gf6a98\n"}]}