Diff and merge tools - jj-vcs/jj GitHub Wiki

Jujutsu uses diff and merge tools for three purposes:

  • Diff viewing.
  • Diff editing edits a revision or selects a subset of changes from a revision. This is used for most --interactive modes.
  • Merging resolves a merge conflict.

Beyond Compare

Beyond Compare is neither free as in freedom nor free as in beer. Only the "Pro" edition seems usable for version control.

They do have a generous free trial. It's "30 days", but this only counts the days you actively use the program.

Beyond Compare can (mostly) substitute for meld for 3-pane diff editing.

Here are some decent configs for Linux.

[merge-tools.bc] 
program = "bcompare" # On MacOS, this should be "bcomp".
edit-args = ["$left", "$right", "-ro1", "-expandall"]
merge-args = ["$left", "$right", "$base", "$output", "-automerge", "-reviewconflicts"]

[merge-tools.bc-3]
# Alternative config similar to `meld-3`.
program="bcompare"  # On MacOS, this should be "bcomp".
edit-args = ["$left", "$right",  "-expandall", "-mergeoutput=$right", "-ro1", "-ro2"]
# Optionally, can copy `merge-args` from the above example

For MacOS, see the comment: you need to use bcomp instead of bcompare.

On Windows, the configuration should be similar but use /blah instead of -blah for options:

[merge-tools.bc]
program = "bcomp"  # You may need to provide a full path to BComp.exe
edit-args = ["$left", "$right", "/leftreadonly", "/expandall"]
merge-args = ["$left", "$right", "$base", "$output", "/automerge", "/reviewconflicts"]

[merge-tools.bc-3]
program = "bcomp"  # You may need to provide a full path to BComp.exe
edit-args = ["$left", "$right", "/expandall", "/mergeoutput=$right", "/leftreadonly", "/rightreadonly"]

Mergiraf

Mergiraf is a "syntax-aware git merge driver for a growing collection of programming languages and file formats".

Since jj 0.27.0, you can use jj resolve --tool mergiraf without any additional configuration required. For reference, here is the default configuration:

[merge-tools.mergiraf]
program = "mergiraf"
merge-args = ["merge", "$base", "$left", "$right", "-o", "$output", "-l", "$marker_length", "--fast"]
merge-conflict-exit-codes = [1]

Currently, the --fast flag often gives the best results because the structural merge algorithm doesn't always maintain comments and spacing in the merge output (even parts without conflicts), but you can remove it if you want to use a full structural merge. Older versions of jj or Mergiraf may not support the -l $marker_length flag, so it may need to be removed if you are not using the latest versions of both tools.

Weave

Weave is an entity-level semantic merge driver. It parses code into semantic entities (functions, classes, methods) via tree-sitter, matches them across versions by identity, and merges at the entity level. Supports 20 languages including TypeScript, Python, Go, Rust, Java, C/C++, Ruby, C#, PHP, Swift, Kotlin, and more.

Install via Homebrew:

brew install weave

Add to your jj config (jj config edit --user):

[merge-tools.weave]
program = "weave-driver"
merge-args = ["$base", "$left", "$right", "-o", "$output", "-l", "$marker_length", "-p", "$path"]
merge-conflict-exit-codes = [1]
merge-tool-edits-conflict-markers = true
conflict-marker-style = "git"

Resolve conflicts with: jj resolve --tool weave

To set as default: jj config set --user ui.merge-editor "weave"