From 3d698cd7c1a2e58ae9263addf57906ad9b349ecc Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 2 Mar 2021 13:36:04 +0900 Subject: [PATCH] Fix tests --- pkg/commands/files.go | 6 +++--- pkg/commands/git_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/commands/files.go b/pkg/commands/files.go index a882d2b87..78e9de38b 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -141,7 +141,7 @@ func (c *GitCommand) WorktreeFileDiff(file *models.File, plain bool, cached bool func (c *GitCommand) WorktreeFileDiffCmdStr(file *models.File, plain bool, cached bool) string { cachedArg := "" - trackedArg := "" + trackedArg := "--" colorArg := c.colorArg() split := strings.Split(file.Name, " -> ") // in case of a renamed file we get the new filename fileName := c.OSCommand.Quote(split[len(split)-1]) @@ -149,13 +149,13 @@ func (c *GitCommand) WorktreeFileDiffCmdStr(file *models.File, plain bool, cache cachedArg = "--cached" } if !file.Tracked && !file.HasStagedChanges && !cached { - trackedArg = "--no-index /dev/null" + trackedArg = "--no-index -- /dev/null" } if plain { colorArg = "never" } - return fmt.Sprintf("git diff --submodule --no-ext-diff --color=%s %s %s -- %s", colorArg, cachedArg, trackedArg, fileName) + return fmt.Sprintf("git diff --submodule --no-ext-diff --color=%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 75f189df8..1f290fbc0 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -1037,7 +1037,7 @@ func TestGitCommandStageFile(t *testing.T) { gitCmd := NewDummyGitCommand() gitCmd.OSCommand.Command = func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"add", "test.txt"}, args) + assert.EqualValues(t, []string{"add", "--", "test.txt"}, args) return secureexec.Command("echo") } @@ -1059,7 +1059,7 @@ func TestGitCommandUnstageFile(t *testing.T) { "Remove an untracked file from staging", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"rm", "--cached", "--force", "test.txt"}, args) + assert.EqualValues(t, []string{"rm", "--cached", "--force", "--", "test.txt"}, args) return secureexec.Command("echo") }, @@ -1072,7 +1072,7 @@ func TestGitCommandUnstageFile(t *testing.T) { "Remove a tracked file from staging", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"reset", "HEAD", "test.txt"}, args) + assert.EqualValues(t, []string{"reset", "HEAD", "--", "test.txt"}, args) return secureexec.Command("echo") }, @@ -1455,7 +1455,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", "--submodule", "--no-ext-diff", "--color=always", "--no-index", "/dev/null", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--submodule", "--no-ext-diff", "--color=always", "--no-index", "--", "/dev/null", "test.txt"}, args) return secureexec.Command("echo") },