jj icon indicating copy to clipboard operation
jj copied to clipboard

FR: Add a "--tool" flag to resolve

Open matts1 opened this issue 2 years ago • 7 comments

Is your feature request related to a problem? Please describe. According to the docs,

  • The ui.merge-editor key specifies the tool used for three-way merge tools by jj 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.

matts1 avatar Nov 13 '23 00:11 matts1

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.

ilyagr avatar Nov 13 '23 17:11 ilyagr

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.

martinvonz avatar Nov 13 '23 17:11 martinvonz

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.

ilyagr avatar Nov 14 '23 00:11 ilyagr

I'd like to take a stab at this is no one else is working on it.

essiene avatar Dec 11 '23 22:12 essiene

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.

martinvonz avatar Dec 11 '23 22:12 martinvonz

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.

essiene avatar Jan 07 '24 21:01 essiene

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).

martinvonz avatar Jan 09 '24 02:01 martinvonz