Skip to content

[Feature] Support jujutsu style diff-editing and conflict resolution #562

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

Open
iofq opened this issue Mar 15, 2025 · 2 comments
Open

[Feature] Support jujutsu style diff-editing and conflict resolution #562

iofq opened this issue Mar 15, 2025 · 2 comments

Comments

@iofq
Copy link

iofq commented Mar 15, 2025

Jujutsu (JJ) is a git-compatible VCS that has grown in popularity recently. https://jj-vcs.github.io

JJ expects to pass a filepath for each of left, right, base and output files to a diff tool, which should display a 3-way merge of the files and save the end result in output. In the case of diff editing, left/right/output can be directories with multiple files. In the case of merge conflict resolution, they would be just one file path each. JJ can provide diff3 style conflict markers.

I'm no VCS expert and I'll be honest don't have a great grasp on what would need to happen here. Wanted to get an issue open to start conversations. My thought is to support diffview at minimum you'd need a command that accepts files e.g. :DiffviewOpen file1 file2 file3 file4.

Some other relevant links:

https://jj-vcs.github.io/jj/latest/config/#setting-up-a-custom-merge-tool
https://github.com/rafikdraoui/jj-diffconflicts
https://github.com/julienvincent/hunk.nvim
https://discord.gg/6S37fk5grK - jujutsu discord

@iofq
Copy link
Author

iofq commented Mar 25, 2025

#286 related

@iofq
Copy link
Author

iofq commented May 9, 2025

for a diff editor (jj squash/split -i), you can use this workaround in jj config.toml:

[ui]
diff-editor = "diffview"

[merge-tools.diffview]
program = "sh"
edit-args = ["-c", '''
  set -eu
  rm -f "$right/JJ-INSTRUCTIONS"
  git -C "$left" init -q
  git -C "$left" add -A
  git -C "$left" commit -q -m baseline --allow-empty
  mv "$left/.git" "$right"
  (cd "$right"; nvim -c "lua require('lazy').load({plugins = {'diffview.nvim'}})" -c DiffviewOpen)
  git -C "$right" add -p
  git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
  git -C "$right" commit -q -m split
  git -C "$right" restore . # undo changes in modified files
  git -C "$right" reset .   # undo --intent-to-add
  git -C "$right" clean -q -df # remove untracked files
''',
]

may need changes to the nvim line based on your neovim setup. You can also just run nvim and then use whatever other git tooling you like.

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

No branches or pull requests

1 participant