diff --git a/pkg/commands/exec_live_default.go b/pkg/commands/exec_live_default.go index 34608bd16..839575d02 100644 --- a/pkg/commands/exec_live_default.go +++ b/pkg/commands/exec_live_default.go @@ -5,14 +5,12 @@ package commands import ( "bufio" "bytes" - "os" "strings" "unicode/utf8" "github.com/go-errors/errors" "github.com/jesseduffield/pty" - "github.com/mgutz/str" ) // RunCommandWithOutputLiveWrapper runs a command and return every word that gets written in stdout @@ -20,10 +18,7 @@ import ( // As return of output you need to give a string that will be written to stdin // NOTE: If the return data is empty it won't written anything to stdin func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) error { - splitCmd := str.ToArgv(command) - cmd := c.command(splitCmd[0], splitCmd[1:]...) - - cmd.Env = os.Environ() + cmd := c.ExecutableFromString(command) cmd.Env = append(cmd.Env, "LANG=en_US.UTF-8", "LC_ALL=en_US.UTF-8") var stderr bytes.Buffer diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 8ef3a1903..2a52ee119 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -622,7 +622,7 @@ func (c *GitCommand) FastForward(branchName string) error { func (c *GitCommand) RunSkipEditorCommand(command string) error { cmd := c.OSCommand.ExecutableFromString(command) cmd.Env = append( - os.Environ(), + cmd.Env, "LAZYGIT_CLIENT_COMMAND=EXIT_IMMEDIATELY", "EDITOR="+c.OSCommand.GetLazygitPath(), ) diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 32d22ea5a..c61404c41 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -78,8 +78,9 @@ func (c *OSCommand) RunExecutable(cmd *exec.Cmd) error { // ExecutableFromString takes a string like `git status` and returns an executable command for it func (c *OSCommand) ExecutableFromString(commandStr string) *exec.Cmd { splitCmd := str.ToArgv(commandStr) - c.Log.Info(splitCmd) - return c.command(splitCmd[0], splitCmd[1:]...) + cmd := c.command(splitCmd[0], splitCmd[1:]...) + cmd.Env = append(os.Environ(), "GIT_OPTIONAL_LOCKS=0") + return cmd } // RunCommandWithOutputLive runs RunCommandWithOutputLiveWrapper @@ -201,8 +202,13 @@ func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error) { } // PrepareSubProcess iniPrepareSubProcessrocess then tells the Gui to switch to it +// TODO: see if this needs to exist, given that ExecutableFromString does the same things func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) *exec.Cmd { - return c.command(cmdName, commandArgs...) + cmd := c.command(cmdName, commandArgs...) + if cmd != nil { + cmd.Env = append(os.Environ(), "GIT_OPTIONAL_LOCKS=0") + } + return cmd } // Quote wraps a message in platform-specific quotation marks