builtin_diff_tree(): make it obvious that function wants two entries

Instead of accepting an array and using exactly two elements from the array, take two single (struct object_array_entry *) arguments. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed May 25, 2013 at 11:08 UTC 91de344d7696ba8d7b92b7c503fdc0d3961e8cd2
1 file changed +10 -9
builtin/diff.c
+10 -9
@@ -153,7 +153,8 @@ static int builtin_diff_index(struct rev_info *revs,
153
154 static int builtin_diff_tree(struct rev_info *revs,
155 int argc, const char **argv,
156 - struct object_array_entry *ent)
156 + struct object_array_entry *ent0,
157 + struct object_array_entry *ent1)
158 {
159 const unsigned char *(sha1[2]);
160 int swap = 0;
@@ -161,13 +162,14 @@ static int builtin_diff_tree(struct rev_info *revs,
162 if (argc > 1)
163 usage(builtin_diff_usage);
164
164 - /* We saw two trees, ent[0] and ent[1].
165 - * if ent[1] is uninteresting, they are swapped
165 + /*
166 + * We saw two trees, ent0 and ent1. If ent1 is uninteresting,
167 + * swap them.
168 */
167 - if (ent[1].item->flags & UNINTERESTING)
169 + if (ent1->item->flags & UNINTERESTING)
170 swap = 1;
169 - sha1[swap] = ent[0].item->sha1;
170 - sha1[1-swap] = ent[1].item->sha1;
171 + sha1[swap] = ent0->item->sha1;
172 + sha1[1-swap] = ent1->item->sha1;
173 diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
174 log_tree_diff_flush(revs);
175 return 0;
@@ -403,7 +405,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
405 else if (ents == 1)
406 result = builtin_diff_index(&rev, argc, argv);
407 else if (ents == 2)
406 - result = builtin_diff_tree(&rev, argc, argv, ent);
408 + result = builtin_diff_tree(&rev, argc, argv, &ent[0], &ent[1]);
409 else if (ent[0].item->flags & UNINTERESTING) {
410 /*
411 * diff A...B where there is at least one merge base
@@ -412,8 +414,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
414 * between the base and B. Note that we pick one
415 * merge base at random if there are more than one.
416 */
415 - ent[1] = ent[ents-1];
416 - result = builtin_diff_tree(&rev, argc, argv, ent);
417 + result = builtin_diff_tree(&rev, argc, argv, &ent[0], &ent[ents-1]);
418 } else
419 result = builtin_diff_combined(&rev, argc, argv,
420 ent, ents);