Skip to content

Commit

Permalink
Use -c core.editor git flag instead of EDITOR environment variable
Browse files Browse the repository at this point in the history
If a user overrides `core.editor` in their .gitconfig, that setting
takes precedence over `$EDITOR`, which breaks the command. Instead,
use the `-c` flag, which has precedence over `.gitconfig`.

commit-id:ce4716a0
  • Loading branch information
amartani authored and Eitan Joffe committed Jan 21, 2022
1 parent 68fd765 commit 36ec360
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git/realgit/realcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func (c *gitcmd) GitWithEditor(argStr string, output *string, editorCmd string)
if c.config.User.LogGitCommands {
fmt.Printf("> git %s\n", argStr)
}
args := strings.Split(argStr, " ")
args := []string{"-c", fmt.Sprintf("core.editor=%s", editorCmd)}
args = append(args, strings.Split(argStr, " ")...)
cmd := exec.Command("git", args...)
cmd.Dir = c.rootdir

cmd.Env = []string{fmt.Sprintf("EDITOR=%s", editorCmd)}
for _, env := range os.Environ() {
parts := strings.SplitN(env, "=", 2)

Expand Down

0 comments on commit 36ec360

Please sign in to comment.