Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octopus-merge (part 4: rewrite tracking in plumbing) #1612

Merged
merged 13 commits into from
Oct 8, 2024
Merged

octopus-merge (part 4: rewrite tracking in plumbing) #1612

merged 13 commits into from
Oct 8, 2024

Conversation

Byron
Copy link
Member

@Byron Byron commented Oct 1, 2024

Integrate everything on plumbing level and create a multi-tree merge with rename support.

Follow-up of #1611.

Tasks

  • tree-diff with 'chunked' directory additions/deletions
    • keep more information for later rename tracking
  • rename-tracking can handle directories with relations
  • rename-tracking built-into tree-diff - pull it down from gix into the lower levels.
    • assure it handles relations - probably there is nothing to do on plumbing level, except for making the information available.
    • port tests
  • gix uses lower-level tree-diff with rewrites
    • add diff_tree_to_tree() to make it way easier to figure out how to perform such a diff.
      • this also helps to make future diffs easier, if they make sense, as status() is its own set of diffs and we could see it that way.

Very Next PR

  • baseline tests for tree-merging
  • make tests pass
    • multi-tree traversal (without wildcard support!) - for now, let's just do it 'the simple' way and perform two diffs
    • optimization idea for when there are numbers: a 'brute force' implementation that uses threads would benefit from the ability to re-use object caches of a repo that has seen the base-tree already, but overall, who knows*
    • there is tests for merging merge-bases in diff3-conflict-markers
    • diff3-conflict-markers.sh - be sure to capture the 'empty tree' label , but also other special cases
    • See also, all the merge options

Next PR / Outscoped

  • Submodule merges are also possible! Maybe outscope it though! libgit2 also doesn't try it.
  • textconv with context, see this gist for details.
    • There seem to be different 'tiers' of tools, some don't get GIT_DIR set, others do.
    • It also seems that diff-programs get too much context right now, but that depends on how much is passed to them by the caller as gix-command::Context.
  • How to model virtual-merge-bases? Can be none or many, user should have control over how this is done.
  • Actual tree-based merging
  • Make blob-merge based conflict handling possible in the tree merge from gix at least. - not needed for now

Research

Everything is about MergeORT.

  • it uses an empty tree if there is no merge-base - we must allow the same.
  • it allows for multiple merge-bases, creating a virtual one by merging all merge-bases together using the same algorithm, recursively.
  • merges can have conflicts without a individual files being involved, for instance when directory renames clash
  • Note that merge-ORT cannot properly handle renames within renamed directories, ending up with the source of the subdir-rename still present.
❯ git ls-tree -r $(git merge-tree main feat)
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    git-sec-renamed/2
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    git-sec-renamed/7
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    git-sec-renamed/subdir/6
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    git-sec/subdir-renamed/6
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    git-sequencer
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    gix/5
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    h
  • Must make sure that possible types of conflicts are properly communicated, to not degenerate information
  • It puts conflict-markers in the blobs of the result tree, with annotations to provide additional context
  • Need resolution configuration, see git2::MergeOptions.
  • data stored by path, and is interned in the map to allow pointer-based comparisons
    • merge-info with everything one needs to know, also related to renames
    • or conflict information
    • it uses a memory-pool/arena to get memory for many paths all at once (and also release it like that)
  • paths start out as conflicted, and then can later be changed to non-conflicting if a content-based merged succeeded.
    • If it remains conflicts, the meta-data is used to produce an 'as merged as possible' version with conflict markers that can be checked out to the working tree.
  • hunks can partially overlap, but can also be resolved line-by line to some extend.

@Byron Byron changed the title octopus-merge (part 4: tree-merge-ORT) octopus-merge (part 4: tree-merge-ORT three-way) Oct 1, 2024
@Byron Byron force-pushed the merge branch 16 times, most recently from bbf6df8 to bb29cdb Compare October 7, 2024 19:20
Deletations that are caused by deletions higher up will now carry
IDs to associate them with each other. This allows to bundle them
at a later stage to re-obtain directory deletions.
Depending on the source of the rename-information, items that are children
of renamed parents may be provided to enable rename tracking based on these
containers, instead of always resorting to tracking leaf nodes (i.e. blobs).
Remove `tree::Changes()` and the ceremony required to diff a tree.
…n plumbing.

This effectively pulls down a higher-level implementation in `gix` to the plumbing
level, to allow it to be used there as well.
This merges `object::tree::diff::change::Event` into `object::tree::diff::Change`
as well.
@Byron Byron force-pushed the merge branch 2 times, most recently from 8e95d68 to 33e7cf2 Compare October 8, 2024 20:28
@Byron Byron marked this pull request as ready for review October 8, 2024 20:28
@Byron Byron enabled auto-merge October 8, 2024 20:29
@Byron Byron merged commit 37c1e4c into main Oct 8, 2024
16 checks passed
@Byron Byron changed the title octopus-merge (part 4: tree-merge-ORT three-way) octopus-merge (part 4: rewrite tracking in plumbing) Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant