diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-01 20:27:06 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-01 20:40:02 +1100 |
commit | eb5418968374a2f4cc3888b24b672d8b5ecdb2ed (patch) | |
tree | aa382cb9b728d556ed24e47558d417cccc067bec /pkg/commands/files.go | |
parent | e8e59306fcd20fb9ef73424f07893bce32edd442 (diff) |
support GIT_EDITOR
Diffstat (limited to 'pkg/commands/files.go')
-rw-r--r-- | pkg/commands/files.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go index 328853a79..5443b7d04 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -315,11 +315,14 @@ func (c *GitCommand) ResetAndClean() error { } // EditFile opens a file in a subprocess using whatever editor is available, -// falling back to core.editor, VISUAL, EDITOR, then vi +// falling back to core.editor, GIT_EDITOR, VISUAL, EDITOR, then vi func (c *GitCommand) EditFile(filename string) (*exec.Cmd, error) { editor := c.GetConfigValue("core.editor") if editor == "" { + editor = c.OSCommand.Getenv("GIT_EDITOR") + } + if editor == "" { editor = c.OSCommand.Getenv("VISUAL") } if editor == "" { @@ -331,7 +334,7 @@ func (c *GitCommand) EditFile(filename string) (*exec.Cmd, error) { } } if editor == "" { - return nil, errors.New("No editor defined in $VISUAL, $EDITOR, or git config") + return nil, errors.New("No editor defined in $GIT_EDITOR, $VISUAL, $EDITOR, or git config") } splitCmd := str.ToArgv(fmt.Sprintf("%s %s", editor, c.OSCommand.Quote(filename))) |