@matheusbsbs / matheus-bagliano / commits / 41d70bd6a9
Fork 0

merge-recursive: Small code clarification -- variable name and comments

process_renames() had a variable named "stage" and derived variables src_other and dst_other whose purpose was not immediately obvious; also, I want to extend the scope of this variable and use it later, so it should have a more descriptive name. Do so, and add a brief comment explaining how it is used and what it relates to. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Sep 20, 2010 at 02:28 UTC 41d70bd6a94d1bd1ec09d2a3d6ebd419abb25bca
1 file changed +14 -6
merge-recursive.c
+14 -6
@@ -924,15 +924,23 @@ static int process_renames(struct merge_options *o,
924 struct string_list_item *item;
925 /* we only use sha1 and mode of these */
926 struct diff_filespec src_other, dst_other;
927 - int try_merge, stage = a_renames == renames1 ? 3: 2;
927 + int try_merge;
928
929 - remove_file(o, 1, ren1_src, o->call_depth || stage == 3);
929 + /*
930 + * unpack_trees loads entries from common-commit
931 + * into stage 1, from head-commit into stage 2, and
932 + * from merge-commit into stage 3. We keep track
933 + * of which side corresponds to the rename.
934 + */
935 + int renamed_stage = a_renames == renames1 ? 2 : 3;
936 + int other_stage = a_renames == renames1 ? 3 : 2;
937
931 - hashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);
932 - src_other.mode = ren1->src_entry->stages[stage].mode;
933 - hashcpy(dst_other.sha1, ren1->dst_entry->stages[stage].sha);
934 - dst_other.mode = ren1->dst_entry->stages[stage].mode;
938 + remove_file(o, 1, ren1_src, o->call_depth || renamed_stage == 2);
939
940 + hashcpy(src_other.sha1, ren1->src_entry->stages[other_stage].sha);
941 + src_other.mode = ren1->src_entry->stages[other_stage].mode;
942 + hashcpy(dst_other.sha1, ren1->dst_entry->stages[other_stage].sha);
943 + dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
944 try_merge = 0;
945
946 if (sha_eq(src_other.sha1, null_sha1)) {