From 05a443cd6eba930a99992a768587d6c50e758df8 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 20 Aug 2021 12:31:32 -0400 Subject: [PATCH] Add unofficial raw argument list support to fugitive#Execute() Hedging our bets for the future. --- autoload/fugitive.vim | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 79a635c..c3887f6 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -632,7 +632,27 @@ function! s:JobOpts(cmd, env) abort endif endfunction -function! s:PrepareJob(...) abort +function! s:PrepareJob(opts) abort + let dict = {'argv': a:opts.argv} + if has_key(a:opts, 'env') + let dict.env = a:opts.env + endif + let [argv, jopts] = s:JobOpts(a:opts.argv, get(a:opts, 'env', {})) + if has_key(a:opts, 'cwd') + if has('patch-8.0.0902') + let jopts.cwd = a:opts.cwd + let dict.cwd = a:opts.cwd + else + throw 'fugitive: cwd unsupported' + endif + endif + return [argv, jopts, dict] +endfunction + +function! fugitive#PrepareJob(...) abort + if a:0 == 1 && type(a:1) == type({}) && has_key(a:1, 'argv') && !has_key(a:1, 'args') + return s:PrepareJob(a:1) + endif let [dir, user_env, exec_env, git, flags, args] = call('fugitive#PrepareDirEnvGitFlagsArgs', a:000) let dict = {'git': git, 'git_dir': dir, 'flags': flags, 'args': args} if len(user_env) @@ -651,7 +671,6 @@ function! s:PrepareJob(...) abort endif endif call extend(cmd, git, 'keep') - let dict.full_argv = cmd return s:JobOpts(cmd, exec_env) + [dict] endfunction @@ -661,7 +680,7 @@ function! fugitive#Execute(...) abort while len(cb) && type(cb[0]) !=# type(function('tr')) call add(cmd, remove(cb, 0)) endwhile - let [argv, jopts, dict] = call('s:PrepareJob', cmd) + let [argv, jopts, dict] = call('fugitive#PrepareJob', cmd) return s:JobExecute(argv, jopts, cb, dict) endfunction @@ -797,7 +816,7 @@ function! s:TreeChomp(...) abort endfunction function! s:StdoutToFile(out, cmd, ...) abort - let [argv, jopts, _] = s:PrepareJob(a:cmd) + let [argv, jopts, _] = fugitive#PrepareJob(a:cmd) let exit = [] if exists('*jobstart') call extend(jopts, {