1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-26 05:37:18 +02:00

Merge pull request #1437 from Ryooooooga/feature/fix-submodule-update

Fix submodule command escaping #1436
This commit is contained in:
Mark Kopenga 2021-08-16 09:48:50 +02:00 committed by GitHub
commit 617e8a05ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {