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>
Elijah Newren committed
Aug 17, 2019 at 11:41 UTC
b4db8a2b768742f4f43d4a6cdb1db39c2ffc9f7f
4 files changed
+22
-12
builtin/checkout.c
+1
-3
@@ -708,7 +708,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
708
* give up or do a real merge, depending on
709
* whether the merge flag was used.
710
*/
711
- struct tree *result;
711
struct tree *work;
712
struct tree *old_tree;
713
struct merge_options o;
@@ -780,8 +779,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
779
ret = merge_trees(&o,
780
new_tree,
781
work,
783
- old_tree,
784
- &result);
782
+ old_tree);
783
if (ret < 0)
784
exit(128);
785
ret = reset_tree(new_tree,
merge-recursive.c
+3
-3
@@ -3623,16 +3623,16 @@ static void merge_finalize(struct merge_options *opt)
3623
int merge_trees(struct merge_options *opt,
3624
struct tree *head,
3625
struct tree *merge,
3626
- struct tree *common,
3627
- struct tree **result)
3626
+ struct tree *common)
3627
{
3628
int clean;
3629
+ struct tree *ignored;
3630
3631
assert(opt->ancestor != NULL);
3632
3633
if (merge_start(opt, head))
3634
return -1;
3635
- clean = merge_trees_internal(opt, head, merge, common, result);
3635
+ clean = merge_trees_internal(opt, head, merge, common, &ignored);
3636
merge_finalize(opt);
3637
3638
return clean;
merge-recursive.h
+16
-4
@@ -74,19 +74,31 @@ static inline int merge_detect_rename(struct merge_options *o)
74
o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
75
}
76
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
+ */
88
int merge_recursive(struct merge_options *o,
89
struct commit *h1,
90
struct commit *h2,
91
struct commit_list *ancestors,
92
struct commit **result);
93
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
+ */
98
int merge_trees(struct merge_options *o,
99
struct tree *head,
100
struct tree *merge,
88
- struct tree *common,
89
- struct tree **result);
101
+ struct tree *common);
102
103
/*
104
* "git-merge-recursive" can be fed trees; wrap them into
sequencer.c
+2
-2
@@ -586,7 +586,7 @@ static int do_recursive_merge(struct repository *r,
586
struct replay_opts *opts)
587
{
588
struct merge_options o;
589
- struct tree *result, *next_tree, *base_tree, *head_tree;
589
+ struct tree *next_tree, *base_tree, *head_tree;
590
int clean;
591
char **xopt;
592
struct lock_file index_lock = LOCK_INIT;
@@ -613,7 +613,7 @@ static int do_recursive_merge(struct repository *r,
613
614
clean = merge_trees(&o,
615
head_tree,
616
- next_tree, base_tree, &result);
616
+ next_tree, base_tree);
617
if (is_rebase_i(opts) && clean <= 0)
618
fputs(o.obuf.buf, stdout);
619
strbuf_release(&o.obuf);