Skip to content

Commit

Permalink
Merge pull request #1434 from Ryooooooga/feature/fix-quote-in-filename
Browse files Browse the repository at this point in the history
the patch panel would crash if the filename contained an odd number of double quotes
  • Loading branch information
mjarkk committed Aug 16, 2021
2 parents 617e8a0 + 0740409 commit 6c415d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/commands/files.go
Expand Up @@ -250,12 +250,12 @@ func (c *GitCommand) ShowFileDiffCmdStr(from string, to string, reverse bool, fi
reverseFlag = " -R "
}

return fmt.Sprintf(`git diff --submodule --no-ext-diff --no-renames --color=%s %s %s %s -- "%s"`, colorArg, from, to, reverseFlag, fileName)
return fmt.Sprintf("git diff --submodule --no-ext-diff --no-renames --color=%s %s %s %s -- %s", colorArg, from, to, reverseFlag, c.OSCommand.Quote(fileName))
}

// CheckoutFile checks out the file for the given commit
func (c *GitCommand) CheckoutFile(commitSha, fileName string) error {
return c.RunCommand("git checkout %s %s", commitSha, fileName)
return c.RunCommand("git checkout %s -- %s", commitSha, c.OSCommand.Quote(fileName))
}

// DiscardOldFileChanges discards changes to a file from an old commit
Expand Down
6 changes: 3 additions & 3 deletions pkg/commands/files_test.go
Expand Up @@ -455,7 +455,7 @@ func TestGitCommandCheckoutFile(t *testing.T) {
"test999.txt",
test.CreateMockCommand(t, []*test.CommandSwapper{
{
Expect: "git checkout 11af912 test999.txt",
Expect: "git checkout 11af912 -- test999.txt",
Replace: "echo",
},
}),
Expand All @@ -469,7 +469,7 @@ func TestGitCommandCheckoutFile(t *testing.T) {
"test999.txt",
test.CreateMockCommand(t, []*test.CommandSwapper{
{
Expect: "git checkout 11af912 test999.txt",
Expect: "git checkout 11af912 -- test999.txt",
Replace: "test",
},
}),
Expand Down Expand Up @@ -606,7 +606,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) {
Replace: "echo",
},
{
Expect: "git checkout HEAD^ test999.txt",
Expect: "git checkout HEAD^ -- test999.txt",
Replace: "echo",
},
{
Expand Down

0 comments on commit 6c415d1

Please sign in to comment.