-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add new merge conflicts menu and move the previous external merge tool there #3477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…l there Also add options for `git checkout --theirs` and `git checkout --ours` Fixes jesseduffield#2026
stefanhaller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start, but it needs some more work.
- Most importantly, it should support range selection. It should be possible to press shift-down-arrow to select multiple files, and then checkout theirs or ours for all of them. This raises the question of what happens if you select both a folder, and some of the files inside it; it seems that you should be able to call
normalisedSelectedNodeswhich was introduced for a similar situation. - I find the terms
theirsandoursproblematic; they are intuitive for a merge conflict, but they appear swapped for a conflict in a rebase. I know that we usually want to stay close to the terms that git CLI uses, but in this case even git CLI admits that the terms can be confusing (there's a long section in the documentation about it). VS Code's conflict browser usesHEAD (Current Change)for ours andIncoming Changefor theirs, which I find a little better. At the very least we should have good tooltips that explain this well. - It would be really good to have some integration tests for this. (You ticked the "Tests have been added/updated" in the PR description, that was cheating. 😄)
| { | ||
| Label: self.c.Tr.CheckoutOurs, | ||
| OnPress: func() error { | ||
| return self.c.Git().WorkingTree.CheckoutOurs(self.context().GetSelected().Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works for top-level files. You want GetPath() instead of Name() so that it also works for files in folders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you should call self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err) after this; this will cause any files that no longer have conflicts to be staged, and if no conflicting files are left, it will prompt to continue the rebase.
I'll look into that - and I didn't quite cheat, I just didn't see that my |
Implements #2026. I also tried to address issues mentioned in the #3477 PR. Previously, pressing `M` opened an external merge tool. Now it opens a merge options menu that allows selecting all conflicts in chosen files as **ours** (HEAD), **theirs** (incoming), or **union** (both), while still providing access to the external merge tool. This uses [git-merge-file](https://git-scm.com/docs/git-merge-file) for a 3-way merge with the `--ours`, `--theirs`, and `--union` flags. This approach avoids the issue mentioned in #1608 (reply in thread), and correctly applies the chosen conflict resolutions while preserving changes from other branches. The command is executed with `--object-id`, which requires object IDs obtained via `rev-parse`, instead of relying on the standard version that works with full saved files.
Also add options for
git checkout --theirsandgit checkout --oursFixes #2026
go generate ./...)docs/Config.md) have been updated if necessary