Override GPG_TTY to prevent terminal garbling

Resolves: https://github.com/tpope/vim-fugitive/issues/1836
This commit is contained in:
Tim Pope
2021-09-13 20:12:38 -04:00
parent 1651cd7f20
commit 5be8263f16

View File

@@ -626,8 +626,10 @@ function! fugitive#PrepareDirEnvGitFlagsArgs(...) abort
if !exists('dir')
let dir = s:Dir()
endif
if !has_key(env, 'GIT_INDEX_FILE')
call s:PrepareEnv(autoenv, dir)
call extend(autoenv, env)
call s:PrepareEnv(autoenv, dir)
if len($GPG_TTY) && !has_key(autoenv, 'GPG_TTY')
let autoenv.GPG_TTY = ''
endif
call s:PreparePathArgs(cmd, dir, literal_pathspecs, explicit_pathspec_option)
return [s:GitDir(dir), env, extend(autoenv, env), git, cmd[0 : -arg_count-1], arg_count ? cmd[-arg_count : -1] : []]
@@ -3637,6 +3639,10 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
\ 'GIT_SEQUENCE_EDITOR': editor,
\ 'GIT_PAGER': 'cat',
\ 'PAGER': 'cat'}, 'keep')
if len($GPG_TTY) && !has_key(env, 'GPG_TTY')
let env.GPG_TTY = ''
let did_override_gpg_tty = 1
endif
if stream
call writefile(['fugitive: aborting edit due to background operation.'], state.file . '.exit')
elseif pager
@@ -3717,6 +3723,9 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
if !explicit_pathspec_option && get(options.flags, 0, '') ==# '--no-literal-pathspecs'
call remove(options.flags, 0)
endif
if exists('l:did_override_gpg_tty')
call remove(env, 'GPG_TTY')
endif
let cmd = s:BuildEnvPrefix(env) . s:shellesc(s:UserCommandList(options) + args)
let after = '|call fugitive#DidChange(' . string(dir) . ')' . after
if !wants_terminal && (no_pager || index(['add', 'clean', 'reset', 'restore', 'stage'], get(args, 0, '')) >= 0 || s:HasOpt(args, ['checkout'], '-q', '--quiet', '--no-progress'))