Skip to content

Commit 1e9d6fa

Browse files
committed
Add new merge conflicts menu and move the previous external merge tool there
Also add options for `git checkout --theirs` and `git checkout --ours` Fixes #2026
1 parent 53f0c4a commit 1e9d6fa

File tree

11 files changed

+63
-12
lines changed

11 files changed

+63
-12
lines changed

docs/keybindings/Keybindings_en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ If you would instead like to start an interactive rebase from the selected commi
143143
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
144144
| `` ` `` | 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. |
145145
| `` <c-t> `` | Open external diff tool (git difftool) | |
146-
| `` M `` | Open external merge tool | Run `git mergetool`. |
146+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
147147
| `` f `` | Fetch | Fetch changes from remote. |
148148
| `` / `` | Search the current view by text | |
149149

docs/keybindings/Keybindings_ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ If you would instead like to start an interactive rebase from the selected commi
213213
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
214214
| `` ` `` | ファイルツリーの表示を切り替え | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
215215
| `` <c-t> `` | Open external diff tool (git difftool) | |
216-
| `` M `` | Git mergetoolを開く | Run `git mergetool`. |
216+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
217217
| `` f `` | Fetch | Fetch changes from remote. |
218218
| `` / `` | 検索を開始 | |
219219

docs/keybindings/Keybindings_ko.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ If you would instead like to start an interactive rebase from the selected commi
352352
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
353353
| `` ` `` | 파일 트리뷰로 전환 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
354354
| `` <c-t> `` | Open external diff tool (git difftool) | |
355-
| `` M `` | Git mergetool를 열기 | Run `git mergetool`. |
355+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
356356
| `` f `` | Fetch | Fetch changes from remote. |
357357
| `` / `` | 검색 시작 | |
358358

docs/keybindings/Keybindings_nl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
7575
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
7676
| `` ` `` | 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. |
7777
| `` <c-t> `` | Open external diff tool (git difftool) | |
78-
| `` M `` | Open external merge tool | Run `git mergetool`. |
78+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
7979
| `` f `` | Fetch | Fetch changes from remote. |
8080
| `` / `` | Start met zoeken | |
8181

docs/keybindings/Keybindings_pl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita,
224224
| `` D `` | Reset | Wyświetl opcje resetu dla drzewa roboczego (np. zniszczenie drzewa roboczego). |
225225
| `` ` `` | 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. |
226226
| `` <c-t> `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | |
227-
| `` M `` | Otwórz zewnętrzne narzędzie scalania | Uruchom `git mergetool`. |
227+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
228228
| `` f `` | Pobierz | Pobierz zmiany ze zdalnego serwera. |
229229
| `` / `` | Szukaj w bieżącym widoku po tekście | |
230230

docs/keybindings/Keybindings_ru.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ If you would instead like to start an interactive rebase from the selected commi
346346
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
347347
| `` ` `` | Переключить вид дерева файлов | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
348348
| `` <c-t> `` | Open external diff tool (git difftool) | |
349-
| `` M `` | Открыть внешний инструмент слияния (git mergetool) | Run `git mergetool`. |
349+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
350350
| `` f `` | Получить изменения | Fetch changes from remote. |
351351
| `` / `` | Найти | |
352352

docs/keybindings/Keybindings_zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ If you would instead like to start an interactive rebase from the selected commi
220220
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
221221
| `` ` `` | 切换文件树视图 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
222222
| `` <c-t> `` | Open external diff tool (git difftool) | |
223-
| `` M `` | 打开外部合并工具 (git mergetool) | Run `git mergetool`. |
223+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
224224
| `` f `` | 抓取 | Fetch changes from remote. |
225225
| `` / `` | 开始搜索 | |
226226

docs/keybindings/Keybindings_zh-TW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ If you would instead like to start an interactive rebase from the selected commi
314314
| `` D `` | Reset | View reset options for working tree (e.g. nuking the working tree). |
315315
| `` ` `` | 顯示檔案樹狀視圖 | Toggle file view between flat and tree layout. Flat layout shows all file paths in a single list, tree layout groups files by directory. |
316316
| `` <c-t> `` | Open external diff tool (git difftool) | |
317-
| `` M `` | 開啟外部合併工具 (git mergetool) | Run `git mergetool`. |
317+
| `` M `` | View merge conflict options | View options for resolving merge conflicts. |
318318
| `` f `` | 擷取 | Fetch changes from remote. |
319319
| `` / `` | 搜尋 | |
320320

pkg/commands/git_commands/working_tree.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,17 @@ func (self *WorkingTreeCommands) ResetMixed(ref string) error {
385385

386386
return self.cmd.New(cmdArgs).Run()
387387
}
388+
389+
func (self *WorkingTreeCommands) CheckoutTheirs(name string) error {
390+
cmdArgs := NewGitCmd("checkout").Arg("--theirs", "--", name).
391+
ToArgv()
392+
393+
return self.cmd.New(cmdArgs).Run()
394+
}
395+
396+
func (self *WorkingTreeCommands) CheckoutOurs(name string) error {
397+
cmdArgs := NewGitCmd("checkout").Arg("--ours", "--", name).
398+
ToArgv()
399+
400+
return self.cmd.New(cmdArgs).Run()
401+
}

pkg/gui/controllers/files_controller.go

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types
174174
Description: self.c.Tr.OpenDiffTool,
175175
},
176176
{
177-
Key: opts.GetKey(opts.Config.Files.OpenMergeTool),
178-
Handler: self.c.Helpers().WorkingTree.OpenMergeTool,
179-
Description: self.c.Tr.OpenMergeTool,
180-
Tooltip: self.c.Tr.OpenMergeToolTooltip,
177+
Key: opts.GetKey(opts.Config.Files.OpenMergeTool),
178+
Handler: self.createMergeConflictToolMenu,
179+
Description: self.c.Tr.ViewMergeConflictOptions,
180+
Tooltip: self.c.Tr.ViewMergeConflictOptionsTooltip,
181+
OpensMenu: true,
182+
DisplayOnScreen: true,
181183
},
182184
{
183185
Key: opts.GetKey(opts.Config.Files.Fetch),
@@ -818,6 +820,33 @@ func (self *FilesController) createStashMenu() error {
818820
})
819821
}
820822

823+
func (self *FilesController) createMergeConflictToolMenu() error {
824+
return self.c.Menu(types.CreateMenuOptions{
825+
Title: self.c.Tr.ViewMergeConflictOptionsTooltip,
826+
Items: []*types.MenuItem{
827+
{
828+
Label: self.c.Tr.OpenMergeTool,
829+
OnPress: self.c.Helpers().WorkingTree.OpenMergeTool,
830+
Key: 'm',
831+
},
832+
{
833+
Label: self.c.Tr.CheckoutOurs,
834+
OnPress: func() error {
835+
return self.c.Git().WorkingTree.CheckoutOurs(self.context().GetSelected().Name())
836+
},
837+
Key: 'o',
838+
},
839+
{
840+
Label: self.c.Tr.CheckoutTheirs,
841+
OnPress: func() error {
842+
return self.c.Git().WorkingTree.CheckoutTheirs(self.context().GetSelected().Name())
843+
},
844+
Key: 't',
845+
},
846+
},
847+
})
848+
}
849+
821850
func (self *FilesController) openCopyMenu() error {
822851
node := self.context().GetSelected()
823852

0 commit comments

Comments
 (0)