diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index d3fa58cca02..becba05ddfc 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -143,7 +143,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | Toggle file tree view | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | Open external merge tool | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | Fetch | Fetch changes from remote. | | `` / `` | Search the current view by text | | diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index 863ecddd4c3..86f6c1bb587 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -213,7 +213,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | ファイルツリーの表示を切り替え | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | Git mergetoolを開く | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | Fetch | Fetch changes from remote. | | `` / `` | 検索を開始 | | diff --git a/docs/keybindings/Keybindings_ko.md b/docs/keybindings/Keybindings_ko.md index 531ed4e4688..f41599e8f5c 100644 --- a/docs/keybindings/Keybindings_ko.md +++ b/docs/keybindings/Keybindings_ko.md @@ -352,7 +352,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | 파일 트리뷰로 전환 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | Git mergetool를 열기 | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | Fetch | Fetch changes from remote. | | `` / `` | 검색 시작 | | diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 61bc9c41475..cebb6be1bce 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -75,7 +75,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | Toggle bestandsboom weergave | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | Open external merge tool | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | Fetch | Fetch changes from remote. | | `` / `` | Start met zoeken | | diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 8c8e5b102c3..1334a9dab7a 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -224,7 +224,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita, | `` D `` | Reset | Wyświetl opcje resetu dla drzewa roboczego (np. zniszczenie drzewa roboczego). | | `` ` `` | Przełącz widok drzewa plików | Przełącz widok plików między płaskim a drzewem. Płaski układ pokazuje wszystkie ścieżki plików na jednej liście, układ drzewa grupuje pliki według katalogów. | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | -| `` M `` | Otwórz zewnętrzne narzędzie scalania | Uruchom `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | Pobierz | Pobierz zmiany ze zdalnego serwera. | | `` / `` | Szukaj w bieżącym widoku po tekście | | diff --git a/docs/keybindings/Keybindings_ru.md b/docs/keybindings/Keybindings_ru.md index 8eb34a5bb39..57623f35ef5 100644 --- a/docs/keybindings/Keybindings_ru.md +++ b/docs/keybindings/Keybindings_ru.md @@ -346,7 +346,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | Переключить вид дерева файлов | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | Открыть внешний инструмент слияния (git mergetool) | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | Получить изменения | Fetch changes from remote. | | `` / `` | Найти | | diff --git a/docs/keybindings/Keybindings_zh-CN.md b/docs/keybindings/Keybindings_zh-CN.md index c6d426b7fb8..238b7a21ee2 100644 --- a/docs/keybindings/Keybindings_zh-CN.md +++ b/docs/keybindings/Keybindings_zh-CN.md @@ -220,7 +220,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | 切换文件树视图 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | 打开外部合并工具 (git mergetool) | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | 抓取 | Fetch changes from remote. | | `` / `` | 开始搜索 | | diff --git a/docs/keybindings/Keybindings_zh-TW.md b/docs/keybindings/Keybindings_zh-TW.md index 2cb92f88e50..cbcdc63c45e 100644 --- a/docs/keybindings/Keybindings_zh-TW.md +++ b/docs/keybindings/Keybindings_zh-TW.md @@ -314,7 +314,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). | | `` ` `` | 顯示檔案樹狀視圖 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. | | `` `` | Open external diff tool (git difftool) | | -| `` M `` | 開啟外部合併工具 (git mergetool) | Run `git mergetool`. | +| `` M `` | View merge conflict options | View options for resolving merge conflicts. | | `` f `` | 擷取 | Fetch changes from remote. | | `` / `` | 搜尋 | | diff --git a/pkg/commands/git_commands/working_tree.go b/pkg/commands/git_commands/working_tree.go index c3338650a94..e705a7e4842 100644 --- a/pkg/commands/git_commands/working_tree.go +++ b/pkg/commands/git_commands/working_tree.go @@ -385,3 +385,17 @@ func (self *WorkingTreeCommands) ResetMixed(ref string) error { return self.cmd.New(cmdArgs).Run() } + +func (self *WorkingTreeCommands) CheckoutTheirs(name string) error { + cmdArgs := NewGitCmd("checkout").Arg("--theirs", "--", name). + ToArgv() + + return self.cmd.New(cmdArgs).Run() +} + +func (self *WorkingTreeCommands) CheckoutOurs(name string) error { + cmdArgs := NewGitCmd("checkout").Arg("--ours", "--", name). + ToArgv() + + return self.cmd.New(cmdArgs).Run() +} diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 25d41cd6fc7..c281cb4a18f 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -174,10 +174,12 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types Description: self.c.Tr.OpenDiffTool, }, { - Key: opts.GetKey(opts.Config.Files.OpenMergeTool), - Handler: self.c.Helpers().WorkingTree.OpenMergeTool, - Description: self.c.Tr.OpenMergeTool, - Tooltip: self.c.Tr.OpenMergeToolTooltip, + Key: opts.GetKey(opts.Config.Files.OpenMergeTool), + Handler: self.createMergeConflictToolMenu, + Description: self.c.Tr.ViewMergeConflictOptions, + Tooltip: self.c.Tr.ViewMergeConflictOptionsTooltip, + OpensMenu: true, + DisplayOnScreen: true, }, { Key: opts.GetKey(opts.Config.Files.Fetch), @@ -818,6 +820,33 @@ func (self *FilesController) createStashMenu() error { }) } +func (self *FilesController) createMergeConflictToolMenu() error { + return self.c.Menu(types.CreateMenuOptions{ + Title: self.c.Tr.ViewMergeConflictOptionsTooltip, + Items: []*types.MenuItem{ + { + Label: self.c.Tr.OpenMergeTool, + OnPress: self.c.Helpers().WorkingTree.OpenMergeTool, + Key: 'm', + }, + { + Label: self.c.Tr.CheckoutOurs, + OnPress: func() error { + return self.c.Git().WorkingTree.CheckoutOurs(self.context().GetSelected().Name()) + }, + Key: 'o', + }, + { + Label: self.c.Tr.CheckoutTheirs, + OnPress: func() error { + return self.c.Git().WorkingTree.CheckoutTheirs(self.context().GetSelected().Name()) + }, + Key: 't', + }, + }, + }) +} + func (self *FilesController) openCopyMenu() error { node := self.context().GetSelected() diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 77e2432ad62..2eaa8a0c696 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -786,6 +786,10 @@ type TranslationSet struct { BreakingChangesTitle string BreakingChangesMessage string BreakingChangesByVersion map[string]string + ViewMergeConflictOptions string + ViewMergeConflictOptionsTooltip string + CheckoutOurs string + CheckoutTheirs string } type Bisect struct { @@ -1740,6 +1744,10 @@ func EnglishTranslationSet() TranslationSet { RangeSelectNotSupportedForSubmodules: "Range select not supported for submodules", OldCherryPickKeyWarning: "The 'c' key is no longer the default key for copying commits to cherry pick. Please use `{{.copy}}` instead (and `{{.paste}}` to paste). The reason for this change is that the 'v' key for selecting a range of lines when staging is now also used for selecting a range of lines in any list view, meaning that we needed to find a new key for pasting commits, and if we're going to now use `{{.paste}}` for pasting commits, we may as well use `{{.copy}}` for copying them. If you want to configure the keybindings to get the old behaviour, set the following in your config:\n\nkeybinding:\n universal:\n toggleRangeSelect: \n commits:\n cherryPickCopy: 'c'\n pasteCommits: 'v'", CommandDoesNotSupportOpeningInEditor: "This command doesn't support switching to the editor", + ViewMergeConflictOptions: "View merge conflict options", + ViewMergeConflictOptionsTooltip: "View options for resolving merge conflicts.", + CheckoutOurs: "Checkout ours", + CheckoutTheirs: "Checkout theirs", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)