This series depends on en/merge-ort-2 (it does NOT depend on en/merge-ort-3 and can thus be reviewed/merged independently of it). This short series adds handling of recursive merges (merging of multiple merge-bases to create a virtual merge base) to merge-ort. With this short series the number of test failures under GIT_TEST_MERGE_ALGORITHM=ort drops by 801 (from 1448 to 647). Changes since v3: * remove the confusing portions of the merge_incore_recursive() API around opt->ancestor that were designed to accommodate merge_recursive_generic() or some function like it. If that stuff is really needed, we can add it later, but it may be better to simply adjust merge_recursive_generic() and/or its callers when we get to that point in the porting process. Elijah Newren (3): merge-ort: copy a few small helper functions from merge-recursive.c merge-ort: make clear_internal_opts() aware of partial clearing merge-ort: implement merge_incore_recursive() merge-ort.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++--- merge-ort.h | 10 ++++ 2 files changed, 135 insertions(+), 7 deletions(-) base-commit: c5a6f65527aa3b6f5d7cf25437a88d8727ab0646 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-814%2Fnewren%2Fort-recursive-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-814/newren/ort-recursive-v4 Pull-Request: https://github.com/gitgitgadget/git/pull/814 Range-diff vs v3: 1: dcf28565ad3 = 1: dcf28565ad3 merge-ort: copy a few small helper functions from merge-recursive.c 2: bffc45c6570 = 2: bffc45c6570 merge-ort: make clear_internal_opts() aware of partial clearing 3: 59216a155ae ! 3: f622d6905d0 merge-ort: implement merge_incore_recursive() @@ merge-ort.c: static void merge_ort_nonrecursive_internal(struct merge_options *o + merged_merge_bases = make_virtual_commit(opt->repo, tree, + "ancestor"); + ancestor_name = "empty tree"; -+ } else if (opt->ancestor && !opt->priv->call_depth) { -+ ancestor_name = opt->ancestor; + } else if (merge_bases) { + ancestor_name = "merged common ancestors"; + } else { @@ merge-ort.c: void merge_incore_recursive(struct merge_options *opt, struct merge_result *result) { - die("Not yet implemented"); -+ /* -+ * merge_incore_nonrecursive() exists for cases where we always -+ * know there is a well-defined single merge base. However, -+ * despite a similar structure, merge-recursive.c noted that some -+ * callers preferred to call the recursive logic anyway and still -+ * set a special name for opt->ancestor that would appear in -+ * merge.conflictStyle=diff3 output. -+ * -+ * git-am was one such example (it wanted to set opt->ancestor to -+ * "constructed merge base", since it created a fake merge base); -+ * it called the recursive merge logic through a special -+ * merge_recursive_generic() wrapper. -+ * -+ * Allow the same kind of special case here. -+ */ -+ int num_merge_bases_is_1 = (merge_bases && !merge_bases->next); -+ assert(opt->ancestor == NULL || num_merge_bases_is_1); ++ /* We set the ancestor label based on the merge_bases */ ++ assert(opt->ancestor == NULL); + + merge_start(opt, result); + merge_ort_internal(opt, merge_bases, side1, side2, result); -- gitgitgadget