diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 9b4fbd544..deb3c43e4 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -558,7 +558,7 @@ func (c *GitCommand) Ignore(filename string) error { } func (c *GitCommand) ShowCmdStr(sha string) string { - return fmt.Sprintf("git show --color --no-renames %s", sha) + return fmt.Sprintf("git show --color --no-renames --stat -p %s", sha) } func (c *GitCommand) GetBranchGraphCmdStr(branchName string) string { @@ -604,7 +604,7 @@ func (c *GitCommand) DiffCmdStr(file *File, plain bool, cached bool) string { colorArg = "" } - return fmt.Sprintf("git diff %s %s %s %s", colorArg, cachedArg, trackedArg, fileName) + return fmt.Sprintf("git diff --stat -p %s %s %s %s", colorArg, cachedArg, trackedArg, fileName) } func (c *GitCommand) ApplyPatch(patch string, flags ...string) error { diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 3c90cc49a..02ed6839b 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -1473,7 +1473,7 @@ func TestGitCommandDiff(t *testing.T) { "Default case", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"diff", "--color", "--", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--stat", "-p", "--color", "--", "test.txt"}, args) return exec.Command("echo") }, @@ -1489,7 +1489,7 @@ func TestGitCommandDiff(t *testing.T) { "cached", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"diff", "--color", "--cached", "--", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--stat", "-p", "--color", "--cached", "--", "test.txt"}, args) return exec.Command("echo") }, @@ -1505,7 +1505,7 @@ func TestGitCommandDiff(t *testing.T) { "plain", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"diff", "--", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--stat", "-p", "--", "test.txt"}, args) return exec.Command("echo") }, @@ -1521,7 +1521,7 @@ func TestGitCommandDiff(t *testing.T) { "File not tracked and file has no staged changes", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"diff", "--color", "--no-index", "/dev/null", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--stat", "-p", "--color", "--no-index", "/dev/null", "test.txt"}, args) return exec.Command("echo") },