From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Elijah Newren <newren@gmail.com>
Subject: [PATCH] merge-recursive: Small code cleanup
Date: Wed, 8 Sep 2010 01:21:22 -0600 [thread overview]
Message-ID: <1283930482-10228-1-git-send-email-newren@gmail.com> (raw)
process_renames() had a variable named "stage" and derived variables
src_other and dst_other whose purpose was not entirely clear to me. Make
the name of stage slightly more descriptive and add a brief comment
explaining what is occurring.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
Was previously PATCH 2/3 from my "fix resolvable rename + D/F conflict
testcases" series, but I've pulled this patch out since it's not
strictly related. Also, due to Ken Schalk's response, I've dropped
the piece of the patch he pointed out an issue in. So now it's just a
smaller cleanup, that is now based on maint.
merge-recursive.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index fb6aa4a..ba9cbab 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -924,15 +924,23 @@ static int process_renames(struct merge_options *o,
struct string_list_item *item;
/* we only use sha1 and mode of these */
struct diff_filespec src_other, dst_other;
- int try_merge, stage = a_renames == renames1 ? 3: 2;
+ int try_merge;
- remove_file(o, 1, ren1_src, o->call_depth || stage == 3);
+ /*
+ * unpack_trees loads entries from common-commit
+ * into stage 1, from head-commit into stage 2, and
+ * from merge-commit into stage 3. We keep track
+ * of which side corresponds to the rename.
+ */
+ int renamed_stage = a_renames == renames1 ? 2 : 3;
+ int other_stage = a_renames == renames1 ? 3 : 2;
- hashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);
- src_other.mode = ren1->src_entry->stages[stage].mode;
- hashcpy(dst_other.sha1, ren1->dst_entry->stages[stage].sha);
- dst_other.mode = ren1->dst_entry->stages[stage].mode;
+ remove_file(o, 1, ren1_src, o->call_depth || renamed_stage == 2);
+ hashcpy(src_other.sha1, ren1->src_entry->stages[other_stage].sha);
+ src_other.mode = ren1->src_entry->stages[other_stage].mode;
+ hashcpy(dst_other.sha1, ren1->dst_entry->stages[other_stage].sha);
+ dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
try_merge = 0;
if (string_list_has_string(&o->current_directory_set, ren1_dst)) {
--
1.7.2.3.7.gf6a98
reply other threads:[~2010-09-08 7:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1283930482-10228-1-git-send-email-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).