* give up or do a real merge, depending on
* whether the merge flag was used.
*/
- struct tree *result;
struct tree *work;
struct tree *old_tree;
struct merge_options o;
ret = merge_trees(&o,
new_tree,
work,
- old_tree,
- &result);
+ old_tree);
if (ret < 0)
exit(128);
ret = reset_tree(new_tree,
int merge_trees(struct merge_options *opt,
struct tree *head,
struct tree *merge,
- struct tree *common,
- struct tree **result)
+ struct tree *common)
{
int clean;
+ struct tree *ignored;
assert(opt->ancestor != NULL);
if (merge_start(opt, head))
return -1;
- clean = merge_trees_internal(opt, head, merge, common, result);
+ clean = merge_trees_internal(opt, head, merge, common, &ignored);
merge_finalize(opt);
return clean;
o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
}
-/* merge_trees() but with recursive ancestor consolidation */
+/*
+ * merge_recursive is like merge_trees() but with recursive ancestor
+ * consolidation, and when successful, it creates an actual commit
+ * and writes its address to *result.
+ *
+ * NOTE: empirically, about a decade ago it was determined that with more
+ * than two merge bases, optimal behavior was found when the
+ * ancestors were passed in the order of oldest merge base to newest
+ * one. Also, ancestors will be consumed (emptied) so make a copy if
+ * you need it.
+ */
int merge_recursive(struct merge_options *o,
struct commit *h1,
struct commit *h2,
struct commit_list *ancestors,
struct commit **result);
-/* rename-detecting three-way merge, no recursion */
+/*
+ * rename-detecting three-way merge, no recursion; result of merge is written
+ * to opt->repo->index.
+ */
int merge_trees(struct merge_options *o,
struct tree *head,
struct tree *merge,
- struct tree *common,
- struct tree **result);
+ struct tree *common);
/*
* "git-merge-recursive" can be fed trees; wrap them into
struct replay_opts *opts)
{
struct merge_options o;
- struct tree *result, *next_tree, *base_tree, *head_tree;
+ struct tree *next_tree, *base_tree, *head_tree;
int clean;
char **xopt;
struct lock_file index_lock = LOCK_INIT;
clean = merge_trees(&o,
head_tree,
- next_tree, base_tree, &result);
+ next_tree, base_tree);
if (is_rebase_i(opts) && clean <= 0)
fputs(o.obuf.buf, stdout);
strbuf_release(&o.obuf);