[PATCH 1/3] read-tree.c: rename local variables used in 3-way merge code.
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:59
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted>
---
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; } ------------