Store more than just dir in s:temp_files

- Also store 'args', the git arguments used to generate the temp file
This commit is contained in:
Quinn Strahl 2014-02-28 21:48:21 -05:00 committed by Tim Pope
parent 8f0b8edfbd
commit 190fe2a4cf

View File

@ -1142,7 +1142,8 @@ function! s:Edit(cmd,bang,...) abort
endif endif
if a:bang if a:bang
let args = s:gsub(join(a:000, ' '), '\\@<!%(\\\\)*\zs[%#]', '\=s:buffer().expand(submatch(0))') let arglist = map(copy(a:000), 's:gsub(v:val, ''\\@<!%(\\\\)*\zs[%#]'', ''\=s:buffer().expand(submatch(0))'')')
let args = join(arglist, ' ')
if a:cmd =~# 'read' if a:cmd =~# 'read'
let git = buffer.repo().git_command() let git = buffer.repo().git_command()
let last = line('$') let last = line('$')
@ -1155,7 +1156,7 @@ function! s:Edit(cmd,bang,...) abort
return 'redraw|echo '.string(':!'.git.' '.args) return 'redraw|echo '.string(':!'.git.' '.args)
else else
let temp = resolve(tempname()) let temp = resolve(tempname())
let s:temp_files[temp] = buffer.repo().dir() let s:temp_files[temp] = { 'dir': buffer.repo().dir(), 'args': arglist }
silent execute a:cmd.' '.temp silent execute a:cmd.' '.temp
if a:cmd =~# 'pedit' if a:cmd =~# 'pedit'
wincmd P wincmd P
@ -1630,7 +1631,8 @@ function! s:Blame(bang,line1,line2,count,args) abort
else else
let cmd += ['--contents', '-'] let cmd += ['--contents', '-']
endif endif
let basecmd = escape(call(s:repo().git_command,cmd+['--',s:buffer().path()],s:repo()),'!') let cmd += ['--', s:buffer().path()]
let basecmd = escape(call(s:repo().git_command,cmd,s:repo()),'!')
try try
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
if !s:repo().bare() if !s:repo().bare()
@ -1671,7 +1673,7 @@ function! s:Blame(bang,line1,line2,count,args) abort
setlocal scrollbind nowrap nofoldenable setlocal scrollbind nowrap nofoldenable
let top = line('w0') + &scrolloff let top = line('w0') + &scrolloff
let current = line('.') let current = line('.')
let s:temp_files[temp] = s:repo().dir() let s:temp_files[temp] = { 'dir': s:repo().dir(), 'args': cmd }
exe 'keepalt leftabove vsplit '.temp exe 'keepalt leftabove vsplit '.temp
let b:fugitive_blamed_bufnr = bufnr let b:fugitive_blamed_bufnr = bufnr
let w:fugitive_leave = restore let w:fugitive_leave = restore
@ -2309,8 +2311,9 @@ augroup fugitive_temp
autocmd! autocmd!
autocmd BufNewFile,BufReadPost * autocmd BufNewFile,BufReadPost *
\ if has_key(s:temp_files,expand('<afile>:p')) | \ if has_key(s:temp_files,expand('<afile>:p')) |
\ let b:git_dir = s:temp_files[expand('<afile>:p')] | \ let b:git_dir = s:temp_files[expand('<afile>:p')].dir |
\ let b:git_type = 'temp' | \ let b:git_type = 'temp' |
\ let b:git_args = s:temp_files[expand('<afile>:p')].args |
\ call fugitive#detect(expand('<afile>:p')) | \ call fugitive#detect(expand('<afile>:p')) |
\ setlocal bufhidden=delete | \ setlocal bufhidden=delete |
\ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>| \ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>|