1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-19 08:09:21 +03:00

Add merge options menu

Replace merge-tool with merge options menu that allows resolving all
conflicts for selected files as ours, theirs, or union, while still
providing access to the merge tool.
This commit is contained in:
Krystof Gartner
2025-09-11 14:09:09 +02:00
committed by Stefan Haller
parent 1f002af06b
commit 703f053a7e
26 changed files with 556 additions and 44 deletions

View File

@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@@ -407,3 +408,46 @@ func (self *WorkingTreeCommands) ResetMixed(ref string) error {
return self.cmd.New(cmdArgs).Run()
}
func (self *WorkingTreeCommands) ShowFileAtStage(path string, stage int) (string, error) {
cmdArgs := NewGitCmd("show").
Arg(fmt.Sprintf(":%d:%s", stage, path)).
ToArgv()
return self.cmd.New(cmdArgs).RunWithOutput()
}
func (self *WorkingTreeCommands) ObjectIDAtStage(path string, stage int) (string, error) {
cmdArgs := NewGitCmd("rev-parse").
Arg(fmt.Sprintf(":%d:%s", stage, path)).
ToArgv()
output, err := self.cmd.New(cmdArgs).RunWithOutput()
if err != nil {
return "", err
}
return strings.TrimSpace(output), nil
}
func (self *WorkingTreeCommands) MergeFileForFiles(strategy string, oursFilepath string, baseFilepath string, theirsFilepath string) (string, error) {
cmdArgs := NewGitCmd("merge-file").
Arg(strategy).
Arg("--stdout").
Arg(oursFilepath, baseFilepath, theirsFilepath).
ToArgv()
return self.cmd.New(cmdArgs).RunWithOutput()
}
// OIDs mode (Git 2.43+)
func (self *WorkingTreeCommands) MergeFileForObjectIDs(strategy string, oursID string, baseID string, theirsID string) (string, error) {
cmdArgs := NewGitCmd("merge-file").
Arg(strategy).
Arg("--stdout").
Arg("--object-id").
Arg(oursID, baseID, theirsID).
ToArgv()
return self.cmd.New(cmdArgs).RunWithOutput()
}