Skip to content

Commit b4db8a2

Browse files
newrengitster
authored andcommitted
merge-recursive: remove useless parameter in merge_trees()
merge_trees() took a results parameter that would only be written when opt->call_depth was positive, which is never the case now that merge_trees_internal() has been split from merge_trees(). Remove the misleading and unused parameter from merge_trees(). While at it, add some comments explaining how the output of merge_trees() and merge_recursive() differ. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 98a1d3d commit b4db8a2

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

builtin/checkout.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
708708
* give up or do a real merge, depending on
709709
* whether the merge flag was used.
710710
*/
711-
struct tree *result;
712711
struct tree *work;
713712
struct tree *old_tree;
714713
struct merge_options o;
@@ -780,8 +779,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
780779
ret = merge_trees(&o,
781780
new_tree,
782781
work,
783-
old_tree,
784-
&result);
782+
old_tree);
785783
if (ret < 0)
786784
exit(128);
787785
ret = reset_tree(new_tree,

merge-recursive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,16 +3623,16 @@ static void merge_finalize(struct merge_options *opt)
36233623
int merge_trees(struct merge_options *opt,
36243624
struct tree *head,
36253625
struct tree *merge,
3626-
struct tree *common,
3627-
struct tree **result)
3626+
struct tree *common)
36283627
{
36293628
int clean;
3629+
struct tree *ignored;
36303630

36313631
assert(opt->ancestor != NULL);
36323632

36333633
if (merge_start(opt, head))
36343634
return -1;
3635-
clean = merge_trees_internal(opt, head, merge, common, result);
3635+
clean = merge_trees_internal(opt, head, merge, common, &ignored);
36363636
merge_finalize(opt);
36373637

36383638
return clean;

merge-recursive.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,31 @@ static inline int merge_detect_rename(struct merge_options *o)
7474
o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
7575
}
7676

77-
/* merge_trees() but with recursive ancestor consolidation */
77+
/*
78+
* merge_recursive is like merge_trees() but with recursive ancestor
79+
* consolidation, and when successful, it creates an actual commit
80+
* and writes its address to *result.
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.
87+
*/
7888
int merge_recursive(struct merge_options *o,
7989
struct commit *h1,
8090
struct commit *h2,
8191
struct commit_list *ancestors,
8292
struct commit **result);
8393

84-
/* rename-detecting three-way merge, no recursion */
94+
/*
95+
* rename-detecting three-way merge, no recursion; result of merge is written
96+
* to opt->repo->index.
97+
*/
8598
int merge_trees(struct merge_options *o,
8699
struct tree *head,
87100
struct tree *merge,
88-
struct tree *common,
89-
struct tree **result);
101+
struct tree *common);
90102

91103
/*
92104
* "git-merge-recursive" can be fed trees; wrap them into

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ static int do_recursive_merge(struct repository *r,
586586
struct replay_opts *opts)
587587
{
588588
struct merge_options o;
589-
struct tree *result, *next_tree, *base_tree, *head_tree;
589+
struct tree *next_tree, *base_tree, *head_tree;
590590
int clean;
591591
char **xopt;
592592
struct lock_file index_lock = LOCK_INIT;
@@ -613,7 +613,7 @@ static int do_recursive_merge(struct repository *r,
613613

614614
clean = merge_trees(&o,
615615
head_tree,
616-
next_tree, base_tree, &result);
616+
next_tree, base_tree);
617617
if (is_rebase_i(opts) && clean <= 0)
618618
fputs(o.obuf.buf, stdout);
619619
strbuf_release(&o.obuf);

0 commit comments

Comments
 (0)