From 5cca4c706393b4445692622924ad2e314e3561a7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 27 Nov 2024 19:40:34 +0100 Subject: [PATCH 1/2] Cleanup: move adding --ignore-all-space arg to DiffCmdObj It is needed by both call sites of this function. This has the added benefit that the argument doesn't unnecessarily show up in the status view when diffing mode is on. --- pkg/commands/git_commands/diff.go | 2 ++ pkg/gui/controllers/helpers/diff_helper.go | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/commands/git_commands/diff.go b/pkg/commands/git_commands/diff.go index 8eb4799b6..aecd66920 100644 --- a/pkg/commands/git_commands/diff.go +++ b/pkg/commands/git_commands/diff.go @@ -19,6 +19,7 @@ func NewDiffCommands(gitCommon *GitCommon) *DiffCommands { func (self *DiffCommands) DiffCmdObj(diffArgs []string) oscommands.ICmdObj { extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand useExtDiff := extDiffCmd != "" + ignoreWhitespace := self.AppState.IgnoreWhitespaceInDiffView return self.cmd.New( NewGitCmd("diff"). @@ -27,6 +28,7 @@ func (self *DiffCommands) DiffCmdObj(diffArgs []string) oscommands.ICmdObj { ArgIfElse(useExtDiff, "--ext-diff", "--no-ext-diff"). Arg("--submodule"). Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)). + ArgIf(ignoreWhitespace, "--ignore-all-space"). Arg(diffArgs...). Dir(self.repoPaths.worktreePath). ToArgv(), diff --git a/pkg/gui/controllers/helpers/diff_helper.go b/pkg/gui/controllers/helpers/diff_helper.go index 0a8c85aa9..2eda84fc1 100644 --- a/pkg/gui/controllers/helpers/diff_helper.go +++ b/pkg/gui/controllers/helpers/diff_helper.go @@ -34,10 +34,6 @@ func (self *DiffHelper) DiffArgs() []string { output = append(output, "-R") } - if self.c.GetAppState().IgnoreWhitespaceInDiffView { - output = append(output, "--ignore-all-space") - } - output = append(output, "--") file := self.currentlySelectedFilename() @@ -59,9 +55,6 @@ func (self *DiffHelper) GetUpdateTaskForRenderingCommitsDiff(commit *models.Comm if refRange != nil { from, to := refRange.From, refRange.To args := []string{from.ParentRefName(), to.RefName(), "--stat", "-p"} - if self.c.GetAppState().IgnoreWhitespaceInDiffView { - args = append(args, "--ignore-all-space") - } args = append(args, "--") if path := self.c.Modes().Filtering.GetPath(); path != "" { args = append(args, path) From 7fb9e8fa9a8983acb312515fbe849d15954a3557 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 27 Nov 2024 19:45:47 +0100 Subject: [PATCH 2/2] Respect the diff context size when showing a range diff This applies to both the "sticky" range diff when diffing mode is on, and the more temporary one when selecting a range of commits. --- pkg/commands/git_commands/diff.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/commands/git_commands/diff.go b/pkg/commands/git_commands/diff.go index aecd66920..d7121db99 100644 --- a/pkg/commands/git_commands/diff.go +++ b/pkg/commands/git_commands/diff.go @@ -29,6 +29,7 @@ func (self *DiffCommands) DiffCmdObj(diffArgs []string) oscommands.ICmdObj { Arg("--submodule"). Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)). ArgIf(ignoreWhitespace, "--ignore-all-space"). + Arg(fmt.Sprintf("--unified=%d", self.AppState.DiffContextSize)). Arg(diffArgs...). Dir(self.repoPaths.worktreePath). ToArgv(),