diffview.nvim icon indicating copy to clipboard operation
diffview.nvim copied to clipboard

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

Open iofq opened this issue 10 months ago • 5 comments

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 avatar Mar 15 '25 09:03 iofq

https://github.com/sindrets/diffview.nvim/issues/286 related

iofq avatar Mar 25 '25 16:03 iofq

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.

iofq avatar May 09 '25 16:05 iofq