git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/6] t1092: use ORT merge strategy

From
Elijah Newren <newren@gmail.com>
Date
Aug 21, 2021, 23:48 UTC
Message-ID
<CABPp-BGkqfx8kHA9o0sYhBQxcN0c_KSrvWczY+KNExhXD3ZeUQ@mail.gmail.com>
In-Reply-To
<xmqqwnofsa24.fsf@gitster.g>
On Fri, Aug 20, 2021 at 9:20 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> >> It seems that merge_recursive() and merge_ort_recursive() are
> >> interface compatible and the latter can serve as a drop-in
> >> replacement for the former?
> >
> > Yes, merge_ort_recursive() and merge_ort_nonrecursive() were meant as
> > interface compatible drop-in replacements for merge_recursive() and
> > merge_trees(), to make it easy to switch callers over.
> >
> > There is no such replacement for merge_recursive_generic(), though,
> > and builtin/{am, merge-recursive, stash}.c will all need to be
> > modified to work with merge-ort.
>
> But merge_recursive_generic() eventually calls into merge_recursive();
> as long as you hook into the latter, you're covered, no?

Okay, you caught me. merge_ort_recursive() has one API difference from merge_recursive(), namely, it does not allow opt->ancestor to be anything other than NULL, whereas merge_recursive() does. The only caller where that distinction matters is merge_recursive_generic()...but that does prevent merge_recursive_generic() from just calling merge_ort_recursive().

The original patches I sent in for merge_incore_recursive() would have provided for this same ability (and made merge_ort_recursive() actually be a drop in replacement), but you rightfully pointed out that the relevant opt->ancestor portion of the patches made no sense. At the time, I responded (at https://lore.kernel.org/git/CABPp-BFr=1iVY739cfh-1Hp82x-Mny-k4y0f3zZ_YuP3PxiGfQ@mail.gmail.com/):

""" Yeah, you're making me lean towards thinking that merge_recursive_generic() is just a broken API that I shouldn't port over (even as a wrapper), and that I further shouldn't support using the merge_ort_recursive() API in a fashion wanted by that function. """

The problem with opt->ancestor in merge_recursive_generic() is as follows:
  * When there is only one merge base (and opt->ancestor is not set),
merge_ort_recursive() and merge_recursive() will both set
opt->ancestor to the hash of the merge base commit.
  * The hash of the merge base is great when the merge base is a real
commit, less so when fake commits are generated (as
merge_recursive_generic() does) to pass along.
  * Because of the above, merge_recursive_generic() overrides
opt->ancestor with the value "constructed merge base" when there is
exactly one merge base tree.  That was done with git-am in mind, and
makes sense for am because it does create a fake or constructed merge
base.  It does not make sense to me for stash, which has a real
commit.  It also seems suboptimal or wrong for
builtin/merge-recursive.c as well -- it's hard to be sure since
builtin/merge-recursive simply takes an OID rather than actual branch
names and thus those OIDs could correspond to fake or constructed
commits, but builtin/merge-recursive does have the
better_branch_name() function it uses for o.branch1 and o.branch2 and
it seems like it should do the same on the merge base when it's
unique.

Rather than porting this bug (these bugs?) over from merge-recursive, I'll just convert the merge_recursive_generic() callers over to the new API.

Previous: Junio C HamanoNext: Derrick Stolee via GitGitGadget
Message 11 of 45 in “Sparse Index: Integrate with merge, cherry-pick, rebase, and revert”
  1. 0/6 Sparse Index: Integrate with merge, cherry-pick, rebase, and revertDerrick Stolee via GitGitGadget, Aug 17, 2021
  2. 1/6 t1092: use ORT merge strategyDerrick Stolee via GitGitGadget, Aug 17, 2021
  3. Taylor BlauAug 18, 2021
  4. Junio C HamanoAug 18, 2021
  5. Derrick StoleeAug 18, 2021
  6. Junio C HamanoAug 18, 2021
  7. Elijah NewrenAug 20, 2021
  8. Junio C HamanoAug 20, 2021
  9. Elijah NewrenAug 21, 2021
  10. Junio C HamanoAug 21, 2021
  11. Elijah NewrenAug 21, 2021
  12. 2/6 diff: ignore sparse paths in diffstatDerrick Stolee via GitGitGadget, Aug 17, 2021
  13. Elijah NewrenAug 20, 2021
  14. Derrick StoleeAug 24, 2021
  15. Elijah NewrenAug 27, 2021
  16. 3/6 merge: make sparse-aware with ORTDerrick Stolee via GitGitGadget, Aug 17, 2021
  17. Elijah NewrenAug 20, 2021
  18. 4/6 merge-ort: expand only for out-of-cone conflictsDerrick Stolee via GitGitGadget, Aug 17, 2021
  19. Elijah NewrenAug 20, 2021
  20. 5/6 t1092: add cherry-pick, rebase testsDerrick Stolee via GitGitGadget, Aug 17, 2021
  21. Elijah NewrenAug 20, 2021
  22. 6/6 sparse-index: integrate with cherry-pick and rebaseDerrick Stolee via GitGitGadget, Aug 17, 2021
  23. Elijah NewrenAug 21, 2021
  24. 0/6 Sparse Index: Integrate with merge, cherry-pick, rebase, and revertDerrick Stolee via GitGitGadget, Aug 24, 2021
  25. 2/6 merge: make sparse-aware with ORTDerrick Stolee via GitGitGadget, Aug 24, 2021
  26. Elijah NewrenAug 27, 2021
  27. Derrick StoleeAug 30, 2021
  28. Derrick StoleeSep 8, 2021
  29. 1/6 diff: ignore sparse paths in diffstatDerrick Stolee via GitGitGadget, Aug 24, 2021
  30. 3/6 merge-ort: expand only for out-of-cone conflictsDerrick Stolee via GitGitGadget, Aug 24, 2021
  31. Elijah NewrenAug 27, 2021
  32. Derrick StoleeAug 30, 2021
  33. 4/6 t1092: add cherry-pick, rebase testsDerrick Stolee via GitGitGadget, Aug 24, 2021
  34. 5/6 sequencer: ensure full index if not ORT strategyDerrick Stolee via GitGitGadget, Aug 24, 2021
  35. 6/6 sparse-index: integrate with cherry-pick and rebaseDerrick Stolee via GitGitGadget, Aug 24, 2021
  36. Elijah NewrenAug 27, 2021
  37. Derrick StoleeAug 30, 2021
  38. 0/6 Sparse Index: Integrate with merge, cherry-pick, rebase, and revertDerrick Stolee via GitGitGadget, Sep 8, 2021
  39. 1/6 diff: ignore sparse paths in diffstatDerrick Stolee via GitGitGadget, Sep 8, 2021
  40. 2/6 merge: make sparse-aware with ORTDerrick Stolee via GitGitGadget, Sep 8, 2021
  41. 4/6 t1092: add cherry-pick, rebase testsDerrick Stolee via GitGitGadget, Sep 8, 2021
  42. 3/6 merge-ort: expand only for out-of-cone conflictsDerrick Stolee via GitGitGadget, Sep 8, 2021
  43. 5/6 sequencer: ensure full index if not ORT strategyDerrick Stolee via GitGitGadget, Sep 8, 2021
  44. 6/6 sparse-index: integrate with cherry-pick and rebaseDerrick Stolee via GitGitGadget, Sep 8, 2021
  45. Elijah NewrenSep 9, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.