merge-recursive: use common name for ancestors/common/base_list

merge_trees(), merge_recursive(), and merge_recursive_generic() in their function headers used four different names for the merge base or list of merge bases they were passed: * 'common' * 'ancestors' * 'ca' * 'base_list' They were able to refer to it four different ways instead of only three by using a different name in the signature for the .c file than the .h file. Change all of these to 'merge_base' or 'merge_bases'. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Aug 17, 2019 at 11:41 UTC ff1bfa2cd5693900a84750dc47cda3cee3cf6ba7
2 files changed +44 -42
merge-recursive.c
+37 -35
@@ -3357,24 +3357,26 @@ static int process_entry(struct merge_options *opt,
3357 static int merge_trees_internal(struct merge_options *opt,
3358 struct tree *head,
3359 struct tree *merge,
3360 - struct tree *common,
3360 + struct tree *merge_base,
3361 struct tree **result)
3362 {
3363 struct index_state *istate = opt->repo->index;
3364 int code, clean;
3365
3366 if (opt->subtree_shift) {
3367 - merge = shift_tree_object(opt->repo, head, merge, opt->subtree_shift);
3368 - common = shift_tree_object(opt->repo, head, common, opt->subtree_shift);
3367 + merge = shift_tree_object(opt->repo, head, merge,
3368 + opt->subtree_shift);
3369 + merge_base = shift_tree_object(opt->repo, head, merge_base,
3370 + opt->subtree_shift);
3371 }
3372
3371 - if (oid_eq(&common->object.oid, &merge->object.oid)) {
3373 + if (oid_eq(&merge_base->object.oid, &merge->object.oid)) {
3374 output(opt, 0, _("Already up to date!"));
3375 *result = head;
3376 return 1;
3377 }
3378
3377 - code = unpack_trees_start(opt, common, head, merge);
3379 + code = unpack_trees_start(opt, merge_base, head, merge);
3380
3381 if (code != 0) {
3382 if (show(opt, 4) || opt->call_depth)
@@ -3402,7 +3404,7 @@ static int merge_trees_internal(struct merge_options *opt,
3404 get_files_dirs(opt, merge);
3405
3406 entries = get_unmerged(opt->repo->index);
3405 - clean = detect_and_process_renames(opt, common, head, merge,
3407 + clean = detect_and_process_renames(opt, merge_base, head, merge,
3408 entries, &re_info);
3409 record_df_conflict_files(opt, entries);
3410 if (clean < 0)
@@ -3470,11 +3472,11 @@ static struct commit_list *reverse_commit_list(struct commit_list *list)
3472 static int merge_recursive_internal(struct merge_options *opt,
3473 struct commit *h1,
3474 struct commit *h2,
3473 - struct commit_list *ca,
3475 + struct commit_list *merge_bases,
3476 struct commit **result)
3477 {
3478 struct commit_list *iter;
3477 - struct commit *merged_common_ancestors;
3479 + struct commit *merged_merge_bases;
3480 struct tree *mrtree;
3481 int clean;
3482 const char *ancestor_name;
@@ -3486,39 +3488,39 @@ static int merge_recursive_internal(struct merge_options *opt,
3488 output_commit_title(opt, h2);
3489 }
3490
3489 - if (!ca) {
3490 - ca = get_merge_bases(h1, h2);
3491 - ca = reverse_commit_list(ca);
3491 + if (!merge_bases) {
3492 + merge_bases = get_merge_bases(h1, h2);
3493 + merge_bases = reverse_commit_list(merge_bases);
3494 }
3495
3496 if (show(opt, 5)) {
3495 - unsigned cnt = commit_list_count(ca);
3497 + unsigned cnt = commit_list_count(merge_bases);
3498
3499 output(opt, 5, Q_("found %u common ancestor:",
3500 "found %u common ancestors:", cnt), cnt);
3499 - for (iter = ca; iter; iter = iter->next)
3501 + for (iter = merge_bases; iter; iter = iter->next)
3502 output_commit_title(opt, iter->item);
3503 }
3504
3503 - merged_common_ancestors = pop_commit(&ca);
3504 - if (merged_common_ancestors == NULL) {
3505 + merged_merge_bases = pop_commit(&merge_bases);
3506 + if (merged_merge_bases == NULL) {
3507 /* if there is no common ancestor, use an empty tree */
3508 struct tree *tree;
3509
3510 tree = lookup_tree(opt->repo, opt->repo->hash_algo->empty_tree);
3509 - merged_common_ancestors = make_virtual_commit(opt->repo,
3510 - tree, "ancestor");
3511 + merged_merge_bases = make_virtual_commit(opt->repo, tree,
3512 + "ancestor");
3513 ancestor_name = "empty tree";
3512 - } else if (ca) {
3514 + } else if (merge_bases) {
3515 ancestor_name = "merged common ancestors";
3516 } else {
3517 strbuf_add_unique_abbrev(&merge_base_abbrev,
3516 - &merged_common_ancestors->object.oid,
3518 + &merged_merge_bases->object.oid,
3519 DEFAULT_ABBREV);
3520 ancestor_name = merge_base_abbrev.buf;
3521 }
3522
3521 - for (iter = ca; iter; iter = iter->next) {
3523 + for (iter = merge_bases; iter; iter = iter->next) {
3524 const char *saved_b1, *saved_b2;
3525 opt->call_depth++;
3526 /*
@@ -3534,14 +3536,14 @@ static int merge_recursive_internal(struct merge_options *opt,
3536 saved_b2 = opt->branch2;
3537 opt->branch1 = "Temporary merge branch 1";
3538 opt->branch2 = "Temporary merge branch 2";
3537 - if (merge_recursive_internal(opt, merged_common_ancestors, iter->item,
3538 - NULL, &merged_common_ancestors) < 0)
3539 + if (merge_recursive_internal(opt, merged_merge_bases, iter->item,
3540 + NULL, &merged_merge_bases) < 0)
3541 return -1;
3542 opt->branch1 = saved_b1;
3543 opt->branch2 = saved_b2;
3544 opt->call_depth--;
3545
3544 - if (!merged_common_ancestors)
3546 + if (!merged_merge_bases)
3547 return err(opt, _("merge returned no commit"));
3548 }
3549
@@ -3554,7 +3556,7 @@ static int merge_recursive_internal(struct merge_options *opt,
3556 repo_get_commit_tree(opt->repo, h1),
3557 repo_get_commit_tree(opt->repo, h2),
3558 repo_get_commit_tree(opt->repo,
3557 - merged_common_ancestors),
3559 + merged_merge_bases),
3560 &mrtree);
3561 strbuf_release(&merge_base_abbrev);
3562 if (clean < 0) {
@@ -3597,7 +3599,7 @@ static void merge_finalize(struct merge_options *opt)
3599 int merge_trees(struct merge_options *opt,
3600 struct tree *head,
3601 struct tree *merge,
3600 - struct tree *common)
3602 + struct tree *merge_base)
3603 {
3604 int clean;
3605 struct tree *ignored;
@@ -3606,7 +3608,7 @@ int merge_trees(struct merge_options *opt,
3608
3609 if (merge_start(opt, head))
3610 return -1;
3609 - clean = merge_trees_internal(opt, head, merge, common, &ignored);
3611 + clean = merge_trees_internal(opt, head, merge, merge_base, &ignored);
3612 merge_finalize(opt);
3613
3614 return clean;
@@ -3615,7 +3617,7 @@ int merge_trees(struct merge_options *opt,
3617 int merge_recursive(struct merge_options *opt,
3618 struct commit *h1,
3619 struct commit *h2,
3618 - struct commit_list *ca,
3620 + struct commit_list *merge_bases,
3621 struct commit **result)
3622 {
3623 int clean;
@@ -3624,7 +3626,7 @@ int merge_recursive(struct merge_options *opt,
3626
3627 if (merge_start(opt, repo_get_commit_tree(opt->repo, h1)))
3628 return -1;
3627 - clean = merge_recursive_internal(opt, h1, h2, ca, result);
3629 + clean = merge_recursive_internal(opt, h1, h2, merge_bases, result);
3630 merge_finalize(opt);
3631
3632 return clean;
@@ -3652,8 +3654,8 @@ static struct commit *get_ref(struct repository *repo,
3654 int merge_recursive_generic(struct merge_options *opt,
3655 const struct object_id *head,
3656 const struct object_id *merge,
3655 - int num_base_list,
3656 - const struct object_id **base_list,
3657 + int num_merge_bases,
3658 + const struct object_id **merge_bases,
3659 struct commit **result)
3660 {
3661 int clean;
@@ -3662,14 +3664,14 @@ int merge_recursive_generic(struct merge_options *opt,
3664 struct commit *next_commit = get_ref(opt->repo, merge, opt->branch2);
3665 struct commit_list *ca = NULL;
3666
3665 - if (base_list) {
3667 + if (merge_bases) {
3668 int i;
3667 - for (i = 0; i < num_base_list; ++i) {
3669 + for (i = 0; i < num_merge_bases; ++i) {
3670 struct commit *base;
3669 - if (!(base = get_ref(opt->repo, base_list[i],
3670 - oid_to_hex(base_list[i]))))
3671 + if (!(base = get_ref(opt->repo, merge_bases[i],
3672 + oid_to_hex(merge_bases[i]))))
3673 return err(opt, _("Could not parse object '%s'"),
3672 - oid_to_hex(base_list[i]));
3674 + oid_to_hex(merge_bases[i]));
3675 commit_list_insert(base, &ca);
3676 }
3677 }
merge-recursive.h
+7 -7
@@ -81,14 +81,14 @@ static inline int merge_detect_rename(struct merge_options *o)
81 *
82 * NOTE: empirically, about a decade ago it was determined that with more
83 * than two merge bases, optimal behavior was found when the
84 - * ancestors were passed in the order of oldest merge base to newest
85 - * one. Also, ancestors will be consumed (emptied) so make a copy if
86 - * you need it.
84 + * merge_bases were passed in the order of oldest commit to newest
85 + * commit. Also, merge_bases will be consumed (emptied) so make a
86 + * copy if you need it.
87 */
88 int merge_recursive(struct merge_options *o,
89 struct commit *h1,
90 struct commit *h2,
91 - struct commit_list *ancestors,
91 + struct commit_list *merge_bases,
92 struct commit **result);
93
94 /*
@@ -98,7 +98,7 @@ int merge_recursive(struct merge_options *o,
98 int merge_trees(struct merge_options *o,
99 struct tree *head,
100 struct tree *merge,
101 - struct tree *common);
101 + struct tree *merge_base);
102
103 /*
104 * "git-merge-recursive" can be fed trees; wrap them into
@@ -107,8 +107,8 @@ int merge_trees(struct merge_options *o,
107 int merge_recursive_generic(struct merge_options *o,
108 const struct object_id *head,
109 const struct object_id *merge,
110 - int num_ca,
111 - const struct object_id **ca,
110 + int num_merge_bases,
111 + const struct object_id **merge_bases,
112 struct commit **result);
113
114 void init_merge_options(struct merge_options *o,