sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.85k stars 105 forks source link

3-way merge conflict: `ours` and `theirs` should not diff each other #297

Closed tummetott closed 1 year ago

tummetott commented 1 year ago

Hey sindrets,

I might have a general question considering the diff capabilities of (neo)vim. When inside a 3 way diff (resolve a merge conflict), is it possible that the ours file is only diffed against the local file, the theirs file is also only diffed against the local file and the local file is diffed against both ours and theirs? Right now it seems that all files are diffed against each other.

What bothers me is the following scenario: The local file shows git conflict markers when opening diffview on a file with merge conflicts. I jump to the first conflict and decide to keep the changes of e.g. ours by pressing 2do. ours and local are now in sync considering the 1st conflict. However, the respective codelines in ours are still highlighted (with the DiffChanged and DiffText or DiffAdd hl-groups), because ours still differ from theirs considering the 1st conflict. In a 3-way diff, I would expect identical codeblocks in ours and local not to be highlighted in ours, independend of the state of theirs. (Respectively, I'd expect that identical codeblocks in local and theirs are not highlighted in theirs, independend of the state ours) Conflicts in ours and theirs will never be resolved in the very same files. Both files are not modifiable. You basically resolve the conflicts in local. Thats why it makes sense for me that they both only diff against local, while local diff against both.

Is this something I could configure (which hooks or some other magic), or am I asking the impossible?

sindrets commented 1 year ago

This is indeed a limitation of how the diff-mode works in (n)vim. You can compare any 2-8 buffers, but every buffer in diff-mode will be compared against every other buffer in diff-mode. You can't selectively choose what buffers are compared against what other buffers unfortunately. You'll have to take this issue upstream.

tummetott commented 1 year ago

Damn ok I'll try to take that issue upstream. Thank you

siulkilulki commented 1 year ago

@tummetott, Could you share the link to the upstream issue?

sindrets commented 1 year ago

https://github.com/neovim/neovim/issues/22144