MCPcopy
hub / github.com/jesseduffield/lazygit / DiffCmdObj

Method DiffCmdObj

pkg/commands/git_commands/diff.go:21–40  ·  view source on GitHub ↗

This is for generating diffs to be shown in the UI (e.g. rendering a range diff to the main view). It uses a custom pager if one is configured.

(diffArgs []string)

Source from the content-addressed store, hash-verified

19// This is for generating diffs to be shown in the UI (e.g. rendering a range
20// diff to the main view). It uses a custom pager if one is configured.
21func (self *DiffCommands) DiffCmdObj(diffArgs []string) *oscommands.CmdObj {
22 extDiffCmd := self.pagerConfig.GetExternalDiffCommand()
23 useExtDiff := extDiffCmd != ""
24 useExtDiffGitConfig := self.pagerConfig.GetUseExternalDiffGitConfig()
25 ignoreWhitespace := self.UserConfig().Git.IgnoreWhitespaceInDiffView
26
27 return self.cmd.New(
28 NewGitCmd("diff").
29 Config("diff.noprefix=false").
30 ConfigIf(useExtDiff, "diff.external="+extDiffCmd).
31 ArgIfElse(useExtDiff || useExtDiffGitConfig, "--ext-diff", "--no-ext-diff").
32 Arg("--submodule").
33 Arg(fmt.Sprintf("--color=%s", self.pagerConfig.GetColorArg())).
34 ArgIf(ignoreWhitespace, "--ignore-all-space").
35 Arg(fmt.Sprintf("--unified=%d", self.UserConfig().Git.DiffContextSize)).
36 Arg(diffArgs...).
37 Dir(self.repoPaths.worktreePath).
38 ToArgv(),
39 )
40}
41
42// This is a basic generic diff command that can be used for any diff operation
43// (e.g. copying a diff to the clipboard). It will not use a custom pager, and

Callers 3

GetOnRenderToMainMethod · 0.80
RenderDiffMethod · 0.80

Calls 14

NewGitCmdFunction · 0.85
UserConfigMethod · 0.80
ToArgvMethod · 0.80
DirMethod · 0.80
ArgMethod · 0.80
ArgIfMethod · 0.80
ArgIfElseMethod · 0.80
ConfigIfMethod · 0.80
GetColorArgMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected