dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.82k stars 364 forks source link

🚀 3 way side-by-side merge conflict #1499

Open RuRo opened 1 year ago

RuRo commented 1 year ago

Currently, 3 way merge conflicts are rendered like this in side-by-side mode:

image

I think, that it would be really cool if we could show a 3 way merge side-by-side in 3 columns instead. Something along the lines of this:

─────────────────────────────────────────────────────────────────────────────────────────────────
• somefile.md:1:
─────────────────────────────────────────────────────────────────────────────────────────────────
   1│ HERE BE BEFORE                   1│ HERE BE BEFORE            1│ HERE BE BEFORE
   2│                                  2│                           2│
▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
                 ┌──────┐                      ┌──────────┐                  ┌──────────┐
                 │ HEAD │           <---       │ ancestor │      --->        │ branch/B │
                 └──────┘                      └──────────┘                  └──────────┘
   3│ This is some file                3│ This is some file          │
    │                                  4│ with many lines in it.     │
    │                                  5│ That's pretty cool         │
    │                                  6│                 innit?     │
   4│ that can't be merged cleanly.     │                           3│ THIS IS SOME FILE
   5│ I'm forced to resolve             │                           4│ WITH MANY LINES IN IT!
   6│ such conflicts routinely!         │                           5│ THAT'S PRETTY COOL
    │                                   │                           6│                 INNIT?!?!
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
   7│                                  7│                           7│
   8│ HERE BE AFTER                    8│ HERE BE AFTER             8│ HERE BE AFTER

P.S. while writing this feature proposal, I've noticed that the line numbers are actually wrong in the current implementation (it counts the lines twice for ancestor ⟶ HEAD and ancestor ⟶ branch/B cases). Also, an already resolved merge commit currently looks kind of broken in side-by-side mode.

searleser97 commented 3 weeks ago

How do you actually get to see this view ? what git command do you run ? thanks

dandavison commented 3 weeks ago

Hi @searleser97, if you have a merge conflict (e.g. from a git merge, or git pull, or git cherry-pick or git rebase etc) then git diff will show this view if you have delta configured as in the delta README. (Or you can do git diff | delta).

To enable side-by-side mode see the delta docs.