From b21ac990ea00fa6db3d52a5432cefbf9cb65af2d Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Mon, 16 Aug 2021 12:34:52 +0900 Subject: fix submodule command escaping #1436 --- pkg/commands/submodules.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'pkg/commands') diff --git a/pkg/commands/submodules.go b/pkg/commands/submodules.go index 856bc4cbe..880b09ab8 100644 --- a/pkg/commands/submodules.go +++ b/pkg/commands/submodules.go @@ -73,7 +73,7 @@ func (c *GitCommand) SubmoduleStash(submodule *models.SubmoduleConfig) error { } func (c *GitCommand) SubmoduleReset(submodule *models.SubmoduleConfig) error { - return c.RunCommand("git submodule update --init --force %s", submodule.Path) + return c.RunCommand("git submodule update --init --force -- %s", c.OSCommand.Quote(submodule.Path)) } func (c *GitCommand) SubmoduleUpdateAll() error { @@ -84,13 +84,13 @@ func (c *GitCommand) SubmoduleUpdateAll() error { func (c *GitCommand) SubmoduleDelete(submodule *models.SubmoduleConfig) error { // based on https://gist.github.com/myusuf3/7f645819ded92bda6677 - if err := c.RunCommand("git submodule deinit --force %s", submodule.Path); err != nil { + if err := c.RunCommand("git submodule deinit --force -- %s", c.OSCommand.Quote(submodule.Path)); err != nil { if strings.Contains(err.Error(), "did not match any file(s) known to git") { - if err := c.RunCommand("git config --file .gitmodules --remove-section submodule.%s", submodule.Name); err != nil { + if err := c.RunCommand("git config --file .gitmodules --remove-section submodule.%s", c.OSCommand.Quote(submodule.Name)); err != nil { return err } - if err := c.RunCommand("git config --remove-section submodule.%s", submodule.Name); err != nil { + if err := c.RunCommand("git config --remove-section submodule.%s", c.OSCommand.Quote(submodule.Name)); err != nil { return err } @@ -119,11 +119,11 @@ func (c *GitCommand) SubmoduleAdd(name string, path string, url string) error { func (c *GitCommand) SubmoduleUpdateUrl(name string, path string, newUrl string) error { // the set-url command is only for later git versions so we're doing it manually here - if err := c.RunCommand("git config --file .gitmodules submodule.%s.url %s", name, newUrl); err != nil { + if err := c.RunCommand("git config --file .gitmodules submodule.%s.url %s", c.OSCommand.Quote(name), newUrl); err != nil { return err } - if err := c.RunCommand("git submodule sync %s", path); err != nil { + if err := c.RunCommand("git submodule sync -- %s", c.OSCommand.Quote(path)); err != nil { return err } @@ -131,11 +131,11 @@ func (c *GitCommand) SubmoduleUpdateUrl(name string, path string, newUrl string) } func (c *GitCommand) SubmoduleInit(path string) error { - return c.RunCommand("git submodule init %s", path) + return c.RunCommand("git submodule init -- %s", c.OSCommand.Quote(path)) } func (c *GitCommand) SubmoduleUpdate(path string) error { - return c.RunCommand("git submodule update --init %s", path) + return c.RunCommand("git submodule update --init -- %s", c.OSCommand.Quote(path)) } func (c *GitCommand) SubmoduleBulkInitCmdStr() string { -- cgit v1.2.3