Skip to content

Commit

Permalink
add GIT_OPTIONAL_LOCKS=0 env var to all commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Jun 6, 2019
1 parent 0f0fda1 commit 3e40369
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 1 addition & 6 deletions pkg/commands/exec_live_default.go
Expand Up @@ -5,25 +5,20 @@ 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
// Output is a function that executes by every word that gets read by bufio
// 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
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/git.go
Expand Up @@ -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(),
)
Expand Down
12 changes: 9 additions & 3 deletions pkg/commands/os.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3e40369

Please sign in to comment.