Skip to content

Commit ff1bfa2

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d7101e commit ff1bfa2

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

merge-recursive.c

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,24 +3357,26 @@ static int process_entry(struct merge_options *opt,
33573357
static int merge_trees_internal(struct merge_options *opt,
33583358
struct tree *head,
33593359
struct tree *merge,
3360-
struct tree *common,
3360+
struct tree *merge_base,
33613361
struct tree **result)
33623362
{
33633363
struct index_state *istate = opt->repo->index;
33643364
int code, clean;
33653365

33663366
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);
33693371
}
33703372

3371-
if (oid_eq(&common->object.oid, &merge->object.oid)) {
3373+
if (oid_eq(&merge_base->object.oid, &merge->object.oid)) {
33723374
output(opt, 0, _("Already up to date!"));
33733375
*result = head;
33743376
return 1;
33753377
}
33763378

3377-
code = unpack_trees_start(opt, common, head, merge);
3379+
code = unpack_trees_start(opt, merge_base, head, merge);
33783380

33793381
if (code != 0) {
33803382
if (show(opt, 4) || opt->call_depth)
@@ -3402,7 +3404,7 @@ static int merge_trees_internal(struct merge_options *opt,
34023404
get_files_dirs(opt, merge);
34033405

34043406
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,
34063408
entries, &re_info);
34073409
record_df_conflict_files(opt, entries);
34083410
if (clean < 0)
@@ -3470,11 +3472,11 @@ static struct commit_list *reverse_commit_list(struct commit_list *list)
34703472
static int merge_recursive_internal(struct merge_options *opt,
34713473
struct commit *h1,
34723474
struct commit *h2,
3473-
struct commit_list *ca,
3475+
struct commit_list *merge_bases,
34743476
struct commit **result)
34753477
{
34763478
struct commit_list *iter;
3477-
struct commit *merged_common_ancestors;
3479+
struct commit *merged_merge_bases;
34783480
struct tree *mrtree;
34793481
int clean;
34803482
const char *ancestor_name;
@@ -3486,39 +3488,39 @@ static int merge_recursive_internal(struct merge_options *opt,
34863488
output_commit_title(opt, h2);
34873489
}
34883490

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);
34923494
}
34933495

34943496
if (show(opt, 5)) {
3495-
unsigned cnt = commit_list_count(ca);
3497+
unsigned cnt = commit_list_count(merge_bases);
34963498

34973499
output(opt, 5, Q_("found %u common ancestor:",
34983500
"found %u common ancestors:", cnt), cnt);
3499-
for (iter = ca; iter; iter = iter->next)
3501+
for (iter = merge_bases; iter; iter = iter->next)
35003502
output_commit_title(opt, iter->item);
35013503
}
35023504

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) {
35053507
/* if there is no common ancestor, use an empty tree */
35063508
struct tree *tree;
35073509

35083510
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");
35113513
ancestor_name = "empty tree";
3512-
} else if (ca) {
3514+
} else if (merge_bases) {
35133515
ancestor_name = "merged common ancestors";
35143516
} else {
35153517
strbuf_add_unique_abbrev(&merge_base_abbrev,
3516-
&merged_common_ancestors->object.oid,
3518+
&merged_merge_bases->object.oid,
35173519
DEFAULT_ABBREV);
35183520
ancestor_name = merge_base_abbrev.buf;
35193521
}
35203522

3521-
for (iter = ca; iter; iter = iter->next) {
3523+
for (iter = merge_bases; iter; iter = iter->next) {
35223524
const char *saved_b1, *saved_b2;
35233525
opt->call_depth++;
35243526
/*
@@ -3534,14 +3536,14 @@ static int merge_recursive_internal(struct merge_options *opt,
35343536
saved_b2 = opt->branch2;
35353537
opt->branch1 = "Temporary merge branch 1";
35363538
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)
35393541
return -1;
35403542
opt->branch1 = saved_b1;
35413543
opt->branch2 = saved_b2;
35423544
opt->call_depth--;
35433545

3544-
if (!merged_common_ancestors)
3546+
if (!merged_merge_bases)
35453547
return err(opt, _("merge returned no commit"));
35463548
}
35473549

@@ -3554,7 +3556,7 @@ static int merge_recursive_internal(struct merge_options *opt,
35543556
repo_get_commit_tree(opt->repo, h1),
35553557
repo_get_commit_tree(opt->repo, h2),
35563558
repo_get_commit_tree(opt->repo,
3557-
merged_common_ancestors),
3559+
merged_merge_bases),
35583560
&mrtree);
35593561
strbuf_release(&merge_base_abbrev);
35603562
if (clean < 0) {
@@ -3597,7 +3599,7 @@ static void merge_finalize(struct merge_options *opt)
35973599
int merge_trees(struct merge_options *opt,
35983600
struct tree *head,
35993601
struct tree *merge,
3600-
struct tree *common)
3602+
struct tree *merge_base)
36013603
{
36023604
int clean;
36033605
struct tree *ignored;
@@ -3606,7 +3608,7 @@ int merge_trees(struct merge_options *opt,
36063608

36073609
if (merge_start(opt, head))
36083610
return -1;
3609-
clean = merge_trees_internal(opt, head, merge, common, &ignored);
3611+
clean = merge_trees_internal(opt, head, merge, merge_base, &ignored);
36103612
merge_finalize(opt);
36113613

36123614
return clean;
@@ -3615,7 +3617,7 @@ int merge_trees(struct merge_options *opt,
36153617
int merge_recursive(struct merge_options *opt,
36163618
struct commit *h1,
36173619
struct commit *h2,
3618-
struct commit_list *ca,
3620+
struct commit_list *merge_bases,
36193621
struct commit **result)
36203622
{
36213623
int clean;
@@ -3624,7 +3626,7 @@ int merge_recursive(struct merge_options *opt,
36243626

36253627
if (merge_start(opt, repo_get_commit_tree(opt->repo, h1)))
36263628
return -1;
3627-
clean = merge_recursive_internal(opt, h1, h2, ca, result);
3629+
clean = merge_recursive_internal(opt, h1, h2, merge_bases, result);
36283630
merge_finalize(opt);
36293631

36303632
return clean;
@@ -3652,8 +3654,8 @@ static struct commit *get_ref(struct repository *repo,
36523654
int merge_recursive_generic(struct merge_options *opt,
36533655
const struct object_id *head,
36543656
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,
36573659
struct commit **result)
36583660
{
36593661
int clean;
@@ -3662,14 +3664,14 @@ int merge_recursive_generic(struct merge_options *opt,
36623664
struct commit *next_commit = get_ref(opt->repo, merge, opt->branch2);
36633665
struct commit_list *ca = NULL;
36643666

3665-
if (base_list) {
3667+
if (merge_bases) {
36663668
int i;
3667-
for (i = 0; i < num_base_list; ++i) {
3669+
for (i = 0; i < num_merge_bases; ++i) {
36683670
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]))))
36713673
return err(opt, _("Could not parse object '%s'"),
3672-
oid_to_hex(base_list[i]));
3674+
oid_to_hex(merge_bases[i]));
36733675
commit_list_insert(base, &ca);
36743676
}
36753677
}

merge-recursive.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ static inline int merge_detect_rename(struct merge_options *o)
8181
*
8282
* NOTE: empirically, about a decade ago it was determined that with more
8383
* 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.
8787
*/
8888
int merge_recursive(struct merge_options *o,
8989
struct commit *h1,
9090
struct commit *h2,
91-
struct commit_list *ancestors,
91+
struct commit_list *merge_bases,
9292
struct commit **result);
9393

9494
/*
@@ -98,7 +98,7 @@ int merge_recursive(struct merge_options *o,
9898
int merge_trees(struct merge_options *o,
9999
struct tree *head,
100100
struct tree *merge,
101-
struct tree *common);
101+
struct tree *merge_base);
102102

103103
/*
104104
* "git-merge-recursive" can be fed trees; wrap them into
@@ -107,8 +107,8 @@ int merge_trees(struct merge_options *o,
107107
int merge_recursive_generic(struct merge_options *o,
108108
const struct object_id *head,
109109
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,
112112
struct commit **result);
113113

114114
void init_merge_options(struct merge_options *o,

0 commit comments

Comments
 (0)