From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: [PATCH 1/3] read-tree.c: rename local variables used in 3-way merge code. Date: Thu, 09 Jun 2005 00:04:49 -0700 Message-ID: <7vhdg8roxa.fsf_-_@assigned-by-dhcp.cox.net> References: <7vis0o30sc.fsf@assigned-by-dhcp.cox.net> <7voeagrp11.fsf_-_@assigned-by-dhcp.cox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu Jun 09 09:03:24 2005 Return-path: Received: from vger.kernel.org ([12.107.209.244]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DgH31-0002Ej-SS for gcvg-git@gmane.org; Thu, 09 Jun 2005 09:01:52 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262306AbVFIHFk (ORCPT ); Thu, 9 Jun 2005 03:05:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262304AbVFIHFk (ORCPT ); Thu, 9 Jun 2005 03:05:40 -0400 Received: from fed1rmmtao02.cox.net ([68.230.241.37]:21245 "EHLO fed1rmmtao02.cox.net") by vger.kernel.org with ESMTP id S262313AbVFIHEv (ORCPT ); Thu, 9 Jun 2005 03:04:51 -0400 Received: from assigned-by-dhcp.cox.net ([68.4.60.172]) by fed1rmmtao02.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050609070449.BNLN22430.fed1rmmtao02.cox.net@assigned-by-dhcp.cox.net>; Thu, 9 Jun 2005 03:04:49 -0400 To: Linus Torvalds In-Reply-To: <7voeagrp11.fsf_-_@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Thu, 09 Jun 2005 00:02:34 -0700") User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org I'd hate to do this, but every time I try to touch this code and validate what it does against the case matrix in t1000 test, I get confused. The variable names are renamed to match the case matrix. Now they are named as: i -- entry from the index file (formerly known as "old") o -- merge base (formerly known as "a") a -- our head (formerly known as "b") b -- merge head (formerly known as "c") Signed-off-by: Junio C Hamano --- read-tree.c | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/read-tree.c b/read-tree.c --- a/read-tree.c +++ b/read-tree.c @@ -40,9 +40,9 @@ static int same(struct cache_entry *a, s * This removes all trivial merges that don't change the tree * and collapses them to state 0. */ -static struct cache_entry *merge_entries(struct cache_entry *a, - struct cache_entry *b, - struct cache_entry *c) +static struct cache_entry *merge_entries(struct cache_entry *o, + struct cache_entry *a, + struct cache_entry *b) { /* * Ok, all three entries describe the same @@ -58,16 +58,16 @@ static struct cache_entry *merge_entries * The "all entries exactly the same" case falls out as * a special case of any of the "two same" cases. * - * Here "a" is "original", and "b" and "c" are the two + * Here "o" is "original", and "a" and "b" are the two * trees we are merging. */ - if (a && b && c) { - if (same(b,c)) - return c; + if (o && a && b) { if (same(a,b)) - return c; - if (same(a,c)) return b; + if (same(o,a)) + return b; + if (same(o,b)) + return a; } return NULL; } @@ -126,29 +126,29 @@ static int merged_entry(struct cache_ent static int threeway_merge(struct cache_entry *stages[4], struct cache_entry **dst) { - struct cache_entry *old = stages[0]; - struct cache_entry *a = stages[1], *b = stages[2], *c = stages[3]; + struct cache_entry *i = stages[0]; + struct cache_entry *o = stages[1], *a = stages[2], *b = stages[3]; struct cache_entry *merge; int count; /* - * If we have an entry in the index cache ("old"), then we want + * If we have an entry in the index cache ("i"), then we want * to make sure that it matches any entries in stage 2 ("first - * branch", aka "b"). + * branch", aka "a"). */ - if (old) { - if (!b || !same(old, b)) + if (i) { + if (!a || !same(i, a)) return -1; } - merge = merge_entries(a, b, c); + merge = merge_entries(o, a, b); if (merge) - return merged_entry(merge, old, dst); - if (old) - verify_uptodate(old); + return merged_entry(merge, i, dst); + if (i) + verify_uptodate(i); count = 0; + if (o) { *dst++ = o; count++; } if (a) { *dst++ = a; count++; } if (b) { *dst++ = b; count++; } - if (c) { *dst++ = c; count++; } return count; } ------------