Skip to content

[POC] git_backend: reference conflict trees in extra parent #5637

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

scott2000
Copy link
Contributor

This is a proof of concept of an alternative way to represent conflicts which would make the git status more clear when a conflicted commit is checked out, as described in #3979 (comment). I mostly just wanted to try it out for fun since I had some free time this weekend; I have no expectation that it'll get merged since it's a pretty large change to how conflicts are represented in the Git backend. 😄

Before:

before

After:

after

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

This representation of conflicts will make `git status` give a more
readable output, and it will prevent files from showing up as new in
editors when the parent of the working copy is a conflicted commit.

The current representation looks something like this (ignoring some
fields in the commit for brevity):

```
commit <conflict>:
  tree <conflict-tree>
  parent <parent>
  jj:trees <side-0> <base-0> <side-1>

tree <conflict-tree>:
  040000 tree <base-0> .jjconflict-base-0
  040000 tree <side-0> .jjconflict-side-0
  040000 tree <side-1> .jjconflict-side-1
  100644 blob <readme> README
```

The new representation will look something like this, with side 0 of the
conflict appearing as the tree of the commit in Git, and the real trees
referenced in a separate commit which is added as an extra parent:

```
commit <conflict>:
  tree <side-0>
  parent <parent>
  parent <conflict-metadata-commit>
  jj:trees-v2 <side-0> <base-0> <side-1>

commit <conflict-metadata-commit>:
  tree <conflict-tree>

tree <conflict-tree>:
  040000 tree <base-0> .jjconflict-base-0
  040000 tree <side-0> .jjconflict-side-0
  040000 tree <side-1> .jjconflict-side-1
```
This file provides a hint if someone checks out a conflicted commit
using Git, similarly to the old "README" that was added with the
conflict trees.
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