diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-04-25 08:53:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 08:53:14 +0200 |
commit | aa81e191e2905e6959f1d8e51c8589764ca0c520 (patch) | |
tree | 1ec97a9cbbb21db35055e781ea8a19ea9b8930a3 | |
parent | b2ff09ec0cb8e10dad405c1d586aa09c8f073c2b (diff) | |
parent | 496308e0230749bd543a78b70fd9ace8a74f0fc5 (diff) |
Support externalDiffCommand in diffing mode (#3519)
- **PR Description**
Support `git.paging.externalDiffCommand` config in diffing mode (i.e.
when showing the diff between two commits using `W`).
Fixes #3518.
-rw-r--r-- | pkg/commands/git_commands/diff.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pkg/commands/git_commands/diff.go b/pkg/commands/git_commands/diff.go index 9f81bb91d..979279914 100644 --- a/pkg/commands/git_commands/diff.go +++ b/pkg/commands/git_commands/diff.go @@ -1,6 +1,10 @@ package git_commands -import "github.com/jesseduffield/lazygit/pkg/commands/oscommands" +import ( + "fmt" + + "github.com/jesseduffield/lazygit/pkg/commands/oscommands" +) type DiffCommands struct { *GitCommon @@ -13,10 +17,16 @@ func NewDiffCommands(gitCommon *GitCommon) *DiffCommands { } func (self *DiffCommands) DiffCmdObj(diffArgs []string) oscommands.ICmdObj { + extDiffCmd := self.UserConfig.Git.Paging.ExternalDiffCommand + useExtDiff := extDiffCmd != "" + return self.cmd.New( NewGitCmd("diff"). Config("diff.noprefix=false"). - Arg("--submodule", "--no-ext-diff", "--color"). + ConfigIf(useExtDiff, "diff.external="+extDiffCmd). + ArgIfElse(useExtDiff, "--ext-diff", "--no-ext-diff"). + Arg("--submodule"). + Arg(fmt.Sprintf("--color=%s", self.UserConfig.Git.Paging.ColorArg)). Arg(diffArgs...). Dir(self.repoPaths.worktreePath). ToArgv(), |