mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-05 15:15:49 +02:00
Merge pull request #2413 from stefanhaller/allow-ignore-whitespace-everywhere
This commit is contained in:
commit
4f7324bad0
@ -18,6 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>W</kbd>: open diff menu
|
<kbd>W</kbd>: open diff menu
|
||||||
<kbd>ctrl+e</kbd>: open diff menu
|
<kbd>ctrl+e</kbd>: open diff menu
|
||||||
<kbd>@</kbd>: open command log menu
|
<kbd>@</kbd>: open command log menu
|
||||||
|
<kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view
|
||||||
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
||||||
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
||||||
<kbd>:</kbd>: execute custom command
|
<kbd>:</kbd>: execute custom command
|
||||||
@ -92,7 +93,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<kbd>ctrl+o</kbd>: copy the file name to the clipboard
|
<kbd>ctrl+o</kbd>: copy the file name to the clipboard
|
||||||
<kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view
|
|
||||||
<kbd>d</kbd>: view 'discard changes' options
|
<kbd>d</kbd>: view 'discard changes' options
|
||||||
<kbd>space</kbd>: toggle staged
|
<kbd>space</kbd>: toggle staged
|
||||||
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
||||||
|
@ -18,6 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>W</kbd>: 差分メニューを開く
|
<kbd>W</kbd>: 差分メニューを開く
|
||||||
<kbd>ctrl+e</kbd>: 差分メニューを開く
|
<kbd>ctrl+e</kbd>: 差分メニューを開く
|
||||||
<kbd>@</kbd>: コマンドログメニューを開く
|
<kbd>@</kbd>: コマンドログメニューを開く
|
||||||
|
<kbd>ctrl+w</kbd>: 空白文字の差分の表示有無を切り替え
|
||||||
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
||||||
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
||||||
<kbd>:</kbd>: カスタムコマンドを実行
|
<kbd>:</kbd>: カスタムコマンドを実行
|
||||||
@ -152,7 +153,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<kbd>ctrl+o</kbd>: ファイル名をクリップボードにコピー
|
<kbd>ctrl+o</kbd>: ファイル名をクリップボードにコピー
|
||||||
<kbd>ctrl+w</kbd>: 空白文字の差分の表示有無を切り替え
|
|
||||||
<kbd>d</kbd>: view 'discard changes' options
|
<kbd>d</kbd>: view 'discard changes' options
|
||||||
<kbd>space</kbd>: ステージ/アンステージ
|
<kbd>space</kbd>: ステージ/アンステージ
|
||||||
<kbd>ctrl+b</kbd>: ファイルをフィルタ (ステージ/アンステージ)
|
<kbd>ctrl+b</kbd>: ファイルをフィルタ (ステージ/アンステージ)
|
||||||
|
@ -18,6 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>W</kbd>: Diff 메뉴 열기
|
<kbd>W</kbd>: Diff 메뉴 열기
|
||||||
<kbd>ctrl+e</kbd>: Diff 메뉴 열기
|
<kbd>ctrl+e</kbd>: Diff 메뉴 열기
|
||||||
<kbd>@</kbd>: 명령어 로그 메뉴 열기
|
<kbd>@</kbd>: 명령어 로그 메뉴 열기
|
||||||
|
<kbd>ctrl+w</kbd>: 공백문자를 Diff 뷰에서 표시 여부 전환
|
||||||
<kbd>}</kbd>: diff 보기의 변경 사항 주위에 표시되는 컨텍스트의 크기를 늘리기
|
<kbd>}</kbd>: diff 보기의 변경 사항 주위에 표시되는 컨텍스트의 크기를 늘리기
|
||||||
<kbd>{</kbd>: diff 보기의 변경 사항 주위에 표시되는 컨텍스트 크기 줄이기
|
<kbd>{</kbd>: diff 보기의 변경 사항 주위에 표시되는 컨텍스트 크기 줄이기
|
||||||
<kbd>:</kbd>: execute custom command
|
<kbd>:</kbd>: execute custom command
|
||||||
@ -271,7 +272,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<kbd>ctrl+o</kbd>: 파일명을 클립보드에 복사
|
<kbd>ctrl+o</kbd>: 파일명을 클립보드에 복사
|
||||||
<kbd>ctrl+w</kbd>: 공백문자를 Diff 뷰에서 표시 여부 전환
|
|
||||||
<kbd>d</kbd>: view 'discard changes' options
|
<kbd>d</kbd>: view 'discard changes' options
|
||||||
<kbd>space</kbd>: Staged 전환
|
<kbd>space</kbd>: Staged 전환
|
||||||
<kbd>ctrl+b</kbd>: 파일을 필터하기 (Staged/unstaged)
|
<kbd>ctrl+b</kbd>: 파일을 필터하기 (Staged/unstaged)
|
||||||
|
@ -18,6 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>W</kbd>: open diff menu
|
<kbd>W</kbd>: open diff menu
|
||||||
<kbd>ctrl+e</kbd>: open diff menu
|
<kbd>ctrl+e</kbd>: open diff menu
|
||||||
<kbd>@</kbd>: open command log menu
|
<kbd>@</kbd>: open command log menu
|
||||||
|
<kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view
|
||||||
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
||||||
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
||||||
<kbd>:</kbd>: voer aangepaste commando uit
|
<kbd>:</kbd>: voer aangepaste commando uit
|
||||||
@ -45,7 +46,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<kbd>ctrl+o</kbd>: kopieer de bestandsnaam naar het klembord
|
<kbd>ctrl+o</kbd>: kopieer de bestandsnaam naar het klembord
|
||||||
<kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view
|
|
||||||
<kbd>d</kbd>: bekijk 'veranderingen ongedaan maken' opties
|
<kbd>d</kbd>: bekijk 'veranderingen ongedaan maken' opties
|
||||||
<kbd>space</kbd>: toggle staged
|
<kbd>space</kbd>: toggle staged
|
||||||
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
||||||
|
@ -18,6 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>W</kbd>: open diff menu
|
<kbd>W</kbd>: open diff menu
|
||||||
<kbd>ctrl+e</kbd>: open diff menu
|
<kbd>ctrl+e</kbd>: open diff menu
|
||||||
<kbd>@</kbd>: open command log menu
|
<kbd>@</kbd>: open command log menu
|
||||||
|
<kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view
|
||||||
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
<kbd>}</kbd>: Increase the size of the context shown around changes in the diff view
|
||||||
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
<kbd>{</kbd>: Decrease the size of the context shown around changes in the diff view
|
||||||
<kbd>:</kbd>: wykonaj własną komendę
|
<kbd>:</kbd>: wykonaj własną komendę
|
||||||
@ -115,7 +116,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<kbd>ctrl+o</kbd>: copy the file name to the clipboard
|
<kbd>ctrl+o</kbd>: copy the file name to the clipboard
|
||||||
<kbd>ctrl+w</kbd>: Toggle whether or not whitespace changes are shown in the diff view
|
|
||||||
<kbd>d</kbd>: pokaż opcje porzucania zmian
|
<kbd>d</kbd>: pokaż opcje porzucania zmian
|
||||||
<kbd>space</kbd>: przełącz stan poczekalni
|
<kbd>space</kbd>: przełącz stan poczekalni
|
||||||
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
||||||
|
@ -18,6 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
<kbd>W</kbd>: 打开 diff 菜单
|
<kbd>W</kbd>: 打开 diff 菜单
|
||||||
<kbd>ctrl+e</kbd>: 打开 diff 菜单
|
<kbd>ctrl+e</kbd>: 打开 diff 菜单
|
||||||
<kbd>@</kbd>: 打开命令日志菜单
|
<kbd>@</kbd>: 打开命令日志菜单
|
||||||
|
<kbd>ctrl+w</kbd>: 切换是否在差异视图中显示空白字符差异
|
||||||
<kbd>}</kbd>: 扩大差异视图中显示的上下文范围
|
<kbd>}</kbd>: 扩大差异视图中显示的上下文范围
|
||||||
<kbd>{</kbd>: 缩小差异视图中显示的上下文范围
|
<kbd>{</kbd>: 缩小差异视图中显示的上下文范围
|
||||||
<kbd>:</kbd>: 执行自定义命令
|
<kbd>:</kbd>: 执行自定义命令
|
||||||
@ -157,7 +158,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<kbd>ctrl+o</kbd>: 将文件名复制到剪贴板
|
<kbd>ctrl+o</kbd>: 将文件名复制到剪贴板
|
||||||
<kbd>ctrl+w</kbd>: 切换是否在差异视图中显示空白字符差异
|
|
||||||
<kbd>d</kbd>: 查看'放弃更改'选项
|
<kbd>d</kbd>: 查看'放弃更改'选项
|
||||||
<kbd>space</kbd>: 切换暂存状态
|
<kbd>space</kbd>: 切换暂存状态
|
||||||
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
<kbd>ctrl+b</kbd>: Filter files (staged/unstaged)
|
||||||
|
@ -118,7 +118,12 @@ func NewGitCommandAux(
|
|||||||
rebaseCommands := git_commands.NewRebaseCommands(gitCommon, commitCommands, workingTreeCommands)
|
rebaseCommands := git_commands.NewRebaseCommands(gitCommon, commitCommands, workingTreeCommands)
|
||||||
stashCommands := git_commands.NewStashCommands(gitCommon, fileLoader, workingTreeCommands)
|
stashCommands := git_commands.NewStashCommands(gitCommon, fileLoader, workingTreeCommands)
|
||||||
// TODO: have patch manager take workingTreeCommands in its entirety
|
// TODO: have patch manager take workingTreeCommands in its entirety
|
||||||
patchManager := patch.NewPatchManager(cmn.Log, workingTreeCommands.ApplyPatch, workingTreeCommands.ShowFileDiff)
|
patchManager := patch.NewPatchManager(cmn.Log, workingTreeCommands.ApplyPatch,
|
||||||
|
func(from string, to string, reverse bool, filename string, plain bool) (string, error) {
|
||||||
|
// TODO: make patch manager take Gui.IgnoreWhitespaceInDiffView into
|
||||||
|
// account. For now we just pass false.
|
||||||
|
return workingTreeCommands.ShowFileDiff(from, to, reverse, filename, plain, false)
|
||||||
|
})
|
||||||
patchCommands := git_commands.NewPatchCommands(gitCommon, rebaseCommands, commitCommands, statusCommands, stashCommands, patchManager)
|
patchCommands := git_commands.NewPatchCommands(gitCommon, rebaseCommands, commitCommands, statusCommands, stashCommands, patchManager)
|
||||||
bisectCommands := git_commands.NewBisectCommands(gitCommon)
|
bisectCommands := git_commands.NewBisectCommands(gitCommon)
|
||||||
|
|
||||||
|
@ -149,14 +149,19 @@ func (self *CommitCommands) AmendHeadCmdObj() oscommands.ICmdObj {
|
|||||||
return self.cmd.New("git commit --amend --no-edit --allow-empty")
|
return self.cmd.New("git commit --amend --no-edit --allow-empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitCommands) ShowCmdObj(sha string, filterPath string) oscommands.ICmdObj {
|
func (self *CommitCommands) ShowCmdObj(sha string, filterPath string, ignoreWhitespace bool) oscommands.ICmdObj {
|
||||||
contextSize := self.UserConfig.Git.DiffContextSize
|
contextSize := self.UserConfig.Git.DiffContextSize
|
||||||
filterPathArg := ""
|
filterPathArg := ""
|
||||||
if filterPath != "" {
|
if filterPath != "" {
|
||||||
filterPathArg = fmt.Sprintf(" -- %s", self.cmd.Quote(filterPath))
|
filterPathArg = fmt.Sprintf(" -- %s", self.cmd.Quote(filterPath))
|
||||||
}
|
}
|
||||||
|
ignoreWhitespaceArg := ""
|
||||||
|
if ignoreWhitespace {
|
||||||
|
ignoreWhitespaceArg = " --ignore-all-space"
|
||||||
|
}
|
||||||
|
|
||||||
cmdStr := fmt.Sprintf("git show --submodule --color=%s --unified=%d --no-renames --stat -p %s %s", self.UserConfig.Git.Paging.ColorArg, contextSize, sha, filterPathArg)
|
cmdStr := fmt.Sprintf("git show --submodule --color=%s --unified=%d --no-renames --stat -p %s%s%s",
|
||||||
|
self.UserConfig.Git.Paging.ColorArg, contextSize, sha, ignoreWhitespaceArg, filterPathArg)
|
||||||
return self.cmd.New(cmdStr).DontLog()
|
return self.cmd.New(cmdStr).DontLog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,30 +177,34 @@ func TestCommitCreateFixupCommit(t *testing.T) {
|
|||||||
|
|
||||||
func TestCommitShowCmdObj(t *testing.T) {
|
func TestCommitShowCmdObj(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
testName string
|
testName string
|
||||||
filterPath string
|
filterPath string
|
||||||
contextSize int
|
contextSize int
|
||||||
expected string
|
ignoreWhitespace bool
|
||||||
|
expected string
|
||||||
}
|
}
|
||||||
|
|
||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
testName: "Default case without filter path",
|
testName: "Default case without filter path",
|
||||||
filterPath: "",
|
filterPath: "",
|
||||||
contextSize: 3,
|
contextSize: 3,
|
||||||
expected: "git show --submodule --color=always --unified=3 --no-renames --stat -p 1234567890 ",
|
ignoreWhitespace: false,
|
||||||
|
expected: "git show --submodule --color=always --unified=3 --no-renames --stat -p 1234567890",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "Default case with filter path",
|
testName: "Default case with filter path",
|
||||||
filterPath: "file.txt",
|
filterPath: "file.txt",
|
||||||
contextSize: 3,
|
contextSize: 3,
|
||||||
expected: `git show --submodule --color=always --unified=3 --no-renames --stat -p 1234567890 -- "file.txt"`,
|
ignoreWhitespace: true,
|
||||||
|
expected: `git show --submodule --color=always --unified=3 --no-renames --stat -p 1234567890 --ignore-all-space -- "file.txt"`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "Show diff with custom context size",
|
testName: "Show diff with custom context size",
|
||||||
filterPath: "",
|
filterPath: "",
|
||||||
contextSize: 77,
|
contextSize: 77,
|
||||||
expected: "git show --submodule --color=always --unified=77 --no-renames --stat -p 1234567890 ",
|
ignoreWhitespace: false,
|
||||||
|
expected: "git show --submodule --color=always --unified=77 --no-renames --stat -p 1234567890",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +216,7 @@ func TestCommitShowCmdObj(t *testing.T) {
|
|||||||
|
|
||||||
instance := buildCommitCommands(commonDeps{userConfig: userConfig})
|
instance := buildCommitCommands(commonDeps{userConfig: userConfig})
|
||||||
|
|
||||||
cmdStr := instance.ShowCmdObj("1234567890", s.filterPath).ToString()
|
cmdStr := instance.ShowCmdObj("1234567890", s.filterPath, s.ignoreWhitespace).ToString()
|
||||||
assert.Equal(t, s.expected, cmdStr)
|
assert.Equal(t, s.expected, cmdStr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -287,11 +287,15 @@ func (self *WorkingTreeCommands) SaveTemporaryPatch(patch string) (string, error
|
|||||||
|
|
||||||
// ShowFileDiff get the diff of specified from and to. Typically this will be used for a single commit so it'll be 123abc^..123abc
|
// ShowFileDiff get the diff of specified from and to. Typically this will be used for a single commit so it'll be 123abc^..123abc
|
||||||
// but when we're in diff mode it could be any 'from' to any 'to'. The reverse flag is also here thanks to diff mode.
|
// but when we're in diff mode it could be any 'from' to any 'to'. The reverse flag is also here thanks to diff mode.
|
||||||
func (self *WorkingTreeCommands) ShowFileDiff(from string, to string, reverse bool, fileName string, plain bool) (string, error) {
|
func (self *WorkingTreeCommands) ShowFileDiff(from string, to string, reverse bool, fileName string, plain bool,
|
||||||
return self.ShowFileDiffCmdObj(from, to, reverse, fileName, plain).RunWithOutput()
|
ignoreWhitespace bool,
|
||||||
|
) (string, error) {
|
||||||
|
return self.ShowFileDiffCmdObj(from, to, reverse, fileName, plain, ignoreWhitespace).RunWithOutput()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *WorkingTreeCommands) ShowFileDiffCmdObj(from string, to string, reverse bool, fileName string, plain bool) oscommands.ICmdObj {
|
func (self *WorkingTreeCommands) ShowFileDiffCmdObj(from string, to string, reverse bool, fileName string, plain bool,
|
||||||
|
ignoreWhitespace bool,
|
||||||
|
) oscommands.ICmdObj {
|
||||||
colorArg := self.UserConfig.Git.Paging.ColorArg
|
colorArg := self.UserConfig.Git.Paging.ColorArg
|
||||||
contextSize := self.UserConfig.Git.DiffContextSize
|
contextSize := self.UserConfig.Git.DiffContextSize
|
||||||
if plain {
|
if plain {
|
||||||
@ -303,11 +307,16 @@ func (self *WorkingTreeCommands) ShowFileDiffCmdObj(from string, to string, reve
|
|||||||
reverseFlag = " -R"
|
reverseFlag = " -R"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignoreWhitespaceFlag := ""
|
||||||
|
if ignoreWhitespace {
|
||||||
|
ignoreWhitespaceFlag = " --ignore-all-space"
|
||||||
|
}
|
||||||
|
|
||||||
return self.cmd.
|
return self.cmd.
|
||||||
New(
|
New(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"git diff --submodule --no-ext-diff --unified=%d --no-renames --color=%s%s%s%s -- %s",
|
"git diff --submodule --no-ext-diff --unified=%d --no-renames --color=%s%s%s%s%s -- %s",
|
||||||
contextSize, colorArg, pad(from), pad(to), reverseFlag, self.cmd.Quote(fileName)),
|
contextSize, colorArg, pad(from), pad(to), reverseFlag, ignoreWhitespaceFlag, self.cmd.Quote(fileName)),
|
||||||
).
|
).
|
||||||
DontLog()
|
DontLog()
|
||||||
}
|
}
|
||||||
|
@ -323,38 +323,52 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
|
|
||||||
func TestWorkingTreeShowFileDiff(t *testing.T) {
|
func TestWorkingTreeShowFileDiff(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
testName string
|
testName string
|
||||||
from string
|
from string
|
||||||
to string
|
to string
|
||||||
reverse bool
|
reverse bool
|
||||||
plain bool
|
plain bool
|
||||||
contextSize int
|
ignoreWhitespace bool
|
||||||
runner *oscommands.FakeCmdObjRunner
|
contextSize int
|
||||||
|
runner *oscommands.FakeCmdObjRunner
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedResult = "pretend this is an actual git diff"
|
const expectedResult = "pretend this is an actual git diff"
|
||||||
|
|
||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
testName: "Default case",
|
testName: "Default case",
|
||||||
from: "1234567890",
|
from: "1234567890",
|
||||||
to: "0987654321",
|
to: "0987654321",
|
||||||
reverse: false,
|
reverse: false,
|
||||||
plain: false,
|
plain: false,
|
||||||
contextSize: 3,
|
ignoreWhitespace: false,
|
||||||
|
contextSize: 3,
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git diff --submodule --no-ext-diff --unified=3 --no-renames --color=always 1234567890 0987654321 -- "test.txt"`, expectedResult, nil),
|
Expect(`git diff --submodule --no-ext-diff --unified=3 --no-renames --color=always 1234567890 0987654321 -- "test.txt"`, expectedResult, nil),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "Show diff with custom context size",
|
testName: "Show diff with custom context size",
|
||||||
from: "1234567890",
|
from: "1234567890",
|
||||||
to: "0987654321",
|
to: "0987654321",
|
||||||
reverse: false,
|
reverse: false,
|
||||||
plain: false,
|
plain: false,
|
||||||
contextSize: 123,
|
ignoreWhitespace: false,
|
||||||
|
contextSize: 123,
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git diff --submodule --no-ext-diff --unified=123 --no-renames --color=always 1234567890 0987654321 -- "test.txt"`, expectedResult, nil),
|
Expect(`git diff --submodule --no-ext-diff --unified=123 --no-renames --color=always 1234567890 0987654321 -- "test.txt"`, expectedResult, nil),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testName: "Default case (ignore whitespace)",
|
||||||
|
from: "1234567890",
|
||||||
|
to: "0987654321",
|
||||||
|
reverse: false,
|
||||||
|
plain: false,
|
||||||
|
ignoreWhitespace: true,
|
||||||
|
contextSize: 3,
|
||||||
|
runner: oscommands.NewFakeRunner(t).
|
||||||
|
Expect(`git diff --submodule --no-ext-diff --unified=3 --no-renames --color=always 1234567890 0987654321 --ignore-all-space -- "test.txt"`, expectedResult, nil),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
@ -365,7 +379,7 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
|
|||||||
|
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig})
|
||||||
|
|
||||||
result, err := instance.ShowFileDiff(s.from, s.to, s.reverse, "test.txt", s.plain)
|
result, err := instance.ShowFileDiff(s.from, s.to, s.reverse, "test.txt", s.plain, s.ignoreWhitespace)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, expectedResult, result)
|
assert.Equal(t, expectedResult, result)
|
||||||
s.runner.CheckForMissingCalls()
|
s.runner.CheckForMissingCalls()
|
||||||
|
@ -15,7 +15,8 @@ func (gui *Gui) commitFilesRenderToMain() error {
|
|||||||
to := ref.RefName()
|
to := ref.RefName()
|
||||||
from, reverse := gui.State.Modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName())
|
from, reverse := gui.State.Modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName())
|
||||||
|
|
||||||
cmdObj := gui.git.WorkingTree.ShowFileDiffCmdObj(from, to, reverse, node.GetPath(), false)
|
cmdObj := gui.git.WorkingTree.ShowFileDiffCmdObj(from, to, reverse, node.GetPath(), false,
|
||||||
|
gui.IgnoreWhitespaceInDiffView)
|
||||||
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
|
|
||||||
pair := gui.c.MainViewPairs().Normal
|
pair := gui.c.MainViewPairs().Normal
|
||||||
|
@ -35,7 +35,8 @@ func (gui *Gui) branchCommitsRenderToMain() error {
|
|||||||
if commit == nil {
|
if commit == nil {
|
||||||
task = types.NewRenderStringTask(gui.c.Tr.NoCommitsThisBranch)
|
task = types.NewRenderStringTask(gui.c.Tr.NoCommitsThisBranch)
|
||||||
} else {
|
} else {
|
||||||
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath())
|
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath(),
|
||||||
|
gui.IgnoreWhitespaceInDiffView)
|
||||||
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,10 @@ func (gui *Gui) diffStr() string {
|
|||||||
output += " -R"
|
output += " -R"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if gui.IgnoreWhitespaceInDiffView {
|
||||||
|
output += " --ignore-all-space"
|
||||||
|
}
|
||||||
|
|
||||||
file := gui.currentlySelectedFilename()
|
file := gui.currentlySelectedFilename()
|
||||||
if file != "" {
|
if file != "" {
|
||||||
output += " -- " + file
|
output += " -- " + file
|
||||||
|
@ -356,7 +356,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
|||||||
Description: self.c.Tr.LcCopySubmoduleNameToClipboard,
|
Description: self.c.Tr.LcCopySubmoduleNameToClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "files",
|
ViewName: "",
|
||||||
Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView),
|
Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView),
|
||||||
Handler: self.toggleWhitespaceInDiffView,
|
Handler: self.toggleWhitespaceInDiffView,
|
||||||
Description: self.c.Tr.ToggleWhitespaceInDiffView,
|
Description: self.c.Tr.ToggleWhitespaceInDiffView,
|
||||||
|
@ -8,7 +8,8 @@ func (gui *Gui) reflogCommitsRenderToMain() error {
|
|||||||
if commit == nil {
|
if commit == nil {
|
||||||
task = types.NewRenderStringTask("No reflog history")
|
task = types.NewRenderStringTask("No reflog history")
|
||||||
} else {
|
} else {
|
||||||
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath())
|
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath(),
|
||||||
|
gui.IgnoreWhitespaceInDiffView)
|
||||||
|
|
||||||
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
@ -658,7 +658,8 @@ func (gui *Gui) refreshPatchBuildingPanel(opts types.OnFocusOpts) error {
|
|||||||
ref := gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.GetRef()
|
ref := gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.GetRef()
|
||||||
to := ref.RefName()
|
to := ref.RefName()
|
||||||
from, reverse := gui.State.Modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName())
|
from, reverse := gui.State.Modes.Diffing.GetFromAndReverseArgsForDiff(ref.ParentRefName())
|
||||||
diff, err := gui.git.WorkingTree.ShowFileDiff(from, to, reverse, path, true)
|
diff, err := gui.git.WorkingTree.ShowFileDiff(from, to, reverse, path, true,
|
||||||
|
gui.IgnoreWhitespaceInDiffView)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ func (gui *Gui) subCommitsRenderToMain() error {
|
|||||||
if commit == nil {
|
if commit == nil {
|
||||||
task = types.NewRenderStringTask("No commits")
|
task = types.NewRenderStringTask("No commits")
|
||||||
} else {
|
} else {
|
||||||
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath())
|
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath(),
|
||||||
|
gui.IgnoreWhitespaceInDiffView)
|
||||||
|
|
||||||
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
)
|
||||||
|
|
||||||
func (gui *Gui) toggleWhitespaceInDiffView() error {
|
func (gui *Gui) toggleWhitespaceInDiffView() error {
|
||||||
gui.IgnoreWhitespaceInDiffView = !gui.IgnoreWhitespaceInDiffView
|
gui.IgnoreWhitespaceInDiffView = !gui.IgnoreWhitespaceInDiffView
|
||||||
|
|
||||||
@ -9,5 +13,5 @@ func (gui *Gui) toggleWhitespaceInDiffView() error {
|
|||||||
}
|
}
|
||||||
gui.c.Toast(toastMessage)
|
gui.c.Toast(toastMessage)
|
||||||
|
|
||||||
return gui.refreshFilesAndSubmodules()
|
return gui.currentSideListContext().HandleFocus(types.OnFocusOpts{})
|
||||||
}
|
}
|
||||||
|
33
pkg/integration/tests/diff/ignore_whitespace.go
Normal file
33
pkg/integration/tests/diff/ignore_whitespace.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package diff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "View diff with and without ignoring whitespace",
|
||||||
|
ExtraCmdArgs: "",
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.CreateFileAndAdd("file1", "first line\nsecond line\n")
|
||||||
|
shell.Commit("first commit")
|
||||||
|
// First line has a real change, second line changes only indentation:
|
||||||
|
shell.UpdateFileAndAdd("file1", "first line changed\n second line\n")
|
||||||
|
shell.Commit("second commit")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Commits().
|
||||||
|
Focus().
|
||||||
|
Tap(func() {
|
||||||
|
// By default, both changes are shown in the diff:
|
||||||
|
t.Views().Main().Content(Contains("-first line\n-second line\n+first line changed\n+ second line\n"))
|
||||||
|
}).
|
||||||
|
Press(keys.Universal.ToggleWhitespaceInDiffView).
|
||||||
|
Tap(func() {
|
||||||
|
// After enabling ignore whitespace, only the real change remains:
|
||||||
|
t.Views().Main().Content(Contains("-first line\n+first line changed\n"))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
@ -68,6 +68,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
diff.Diff,
|
diff.Diff,
|
||||||
diff.DiffAndApplyPatch,
|
diff.DiffAndApplyPatch,
|
||||||
diff.DiffCommits,
|
diff.DiffCommits,
|
||||||
|
diff.IgnoreWhitespace,
|
||||||
sync.FetchPrune,
|
sync.FetchPrune,
|
||||||
sync.RenameBranchAndPull,
|
sync.RenameBranchAndPull,
|
||||||
filter_by_path.CliArg,
|
filter_by_path.CliArg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user