1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Merge pull request #1434 from Ryooooooga/feature/fix-quote-in-filename

the patch panel would crash if the filename contained an odd number of double quotes
This commit is contained in:
Mark Kopenga
2021-08-16 09:52:06 +02:00
committed by GitHub
2 changed files with 5 additions and 5 deletions

View File

@ -250,12 +250,12 @@ func (c *GitCommand) ShowFileDiffCmdStr(from string, to string, reverse bool, fi
reverseFlag = " -R " 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 // CheckoutFile checks out the file for the given commit
func (c *GitCommand) CheckoutFile(commitSha, fileName string) error { 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 // DiscardOldFileChanges discards changes to a file from an old commit

View File

@ -455,7 +455,7 @@ func TestGitCommandCheckoutFile(t *testing.T) {
"test999.txt", "test999.txt",
test.CreateMockCommand(t, []*test.CommandSwapper{ test.CreateMockCommand(t, []*test.CommandSwapper{
{ {
Expect: "git checkout 11af912 test999.txt", Expect: "git checkout 11af912 -- test999.txt",
Replace: "echo", Replace: "echo",
}, },
}), }),
@ -469,7 +469,7 @@ func TestGitCommandCheckoutFile(t *testing.T) {
"test999.txt", "test999.txt",
test.CreateMockCommand(t, []*test.CommandSwapper{ test.CreateMockCommand(t, []*test.CommandSwapper{
{ {
Expect: "git checkout 11af912 test999.txt", Expect: "git checkout 11af912 -- test999.txt",
Replace: "test", Replace: "test",
}, },
}), }),
@ -606,7 +606,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) {
Replace: "echo", Replace: "echo",
}, },
{ {
Expect: "git checkout HEAD^ test999.txt", Expect: "git checkout HEAD^ -- test999.txt",
Replace: "echo", Replace: "echo",
}, },
{ {