-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shortcuts to compare incoming/current with common ancestor
Git has a diff style `diff3` or `zdiff3` that shows the common ancestor of two conflicting commits in the conflict. For example: ``` <<<<<<< HEAD int c = 2; ||||||| parent of ed293d1 (Capitalise) int c; ======= int C; >>>>>>> ed293d1 (Capitalise) ``` This is enormously useful when resolving conflicts. However sometimes git is dumb and you end up with conflicts that are difficult to follow. For example suppose you have some `really long old code`, and you write some `new code` to replace it. You rebase your change, and find that someone has made a tiny tiny change *somewhere* in the really long old code. It *might* be relevant - it could be some change that you also need to apply to your new code. But the conflict just looks like this: ``` <<<<<<< HEAD really long old code ||||||| parent of ed293d1 (Capitalise) really Long old code ======= new code >>>>>>> ed293d1 (Capitalise) ``` Not too bad with 4 lines but sometimes it's hundreds, and then you end up visually diffing it, like a cave man. There is an existing `Compare Changes` option, but it only compares `Current` with `Incoming`. This commit adds two more options to compare the common ancestor with `Current` or `Incoming` instead, thus solving the problem once and for all. This was mostly straightforward. The two tricky bits are: 1. Apparently you can have more than one common ancestor. I've never seen that so I just don't show the buttons in that case (or pick the first common ancestor if you use the command palette). 2. What if you don't have `diff3` and still run the new compare commands from the command palette? In that case it falls back to not showing any changes.
- Loading branch information
Showing
4 changed files
with
105 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters