FR: Add a "--tool" flag to resolve
Is your feature request related to a problem? Please describe. According to the docs,
- The
ui.merge-editorkey specifies the tool used for three-way merge tools byjj resolve - You can run
jj diff --tool=<tool>to specify which tool to use to diff
It makes sense to also add this flag for conflict resolution.
Describe the solution you'd like
Describe alternatives you've considered
Additional context Add any other context or screenshots about the feature request here.
Makes sense.
This would also make sense for the diff editor used by jj split, jj move -i, etc.
At the moment, a workaround is to run jj --config-toml='ui.merge-editor="TOOL"' resolve.
This can be made easier with a shell script, see https://github.com/martinvonz/jj/issues/2575#issuecomment-1809328839 below.
The way we do alias expansion means that you might not even need a shell script for it; you can define an alias like this:
[aliases]
meld = ['--config-toml', 'ui.merge-editor="meld"']
And then use it with jj meld resolve. Strange but true.
You can go even fancier:
[aliases]
meld = ['--config-toml', 'ui.merge-editor="meld"',
'--config-toml', 'ui.diff-editor="meld-3"',
'--config-toml', 'ui.diff.tool="meld"',
]
Alternatively, here's the script I was thinking of. I called it jj.tool:
#!/bin/sh
TOOL="$1"
shift
jj --config-toml "[ui]
diff-editor = \"$TOOL\"
merge-editor = \"$TOOL\"
diff.tool = \"$TOOL\"" "$@";
It might be more readable if it had several --config-toml-s, like the alias example.
I'd like to take a stab at this is no one else is working on it.
I'd like to take a stab at this is no one else is working on it.
Thanks! I've assigned this and #1457 to you.
Is the --tool flag limited to only diff related external tools?
I don't know enough yet, but I'm wondering if we want to be able to easily "opt-in" a command to take a --tool flag, which can be any external command.
I will propose an approach to see if it makes sense, but I want to know what seems like a good direction in general.
I think the merge tools generally take multiple arguments so just pointing to a binary is not enough. See https://martinvonz.github.io/jj/v0.13.0/config/#setting-up-a-custom-merge-tool for how they're configured. I think we'll want --tool to take a name pointing into that config section (i.e. kdiff3, meld or kdiff3 in the example on that page).