Skip to content

Commit

Permalink
Support externalDiffCommand in diffing mode (#3519)
Browse files Browse the repository at this point in the history
- **PR Description**

Support `git.paging.externalDiffCommand` config in diffing mode (i.e.
when showing the diff between two commits using `W`).

Fixes #3518.
  • Loading branch information
stefanhaller committed Apr 25, 2024
2 parents b2ff09e + 496308e commit aa81e19
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/commands/git_commands/diff.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(),
Expand Down

0 comments on commit aa81e19

Please sign in to comment.