Eliminate use of buffer.commit()
Can't add a s:Commit() helper because that's the :Gcommit implementation function, dang it.
This commit is contained in:
parent
bfc1745f3b
commit
240127f5a5
@ -1544,8 +1544,9 @@ function! s:Log(cmd, line1, line2, ...) abort
|
|||||||
let cmd = ['--no-pager', 'log', '--no-color']
|
let cmd = ['--no-pager', 'log', '--no-color']
|
||||||
let cmd += ['--pretty=format:fugitive://'.s:repo().dir().'//%H'.path.'::'.g:fugitive_summary_format]
|
let cmd += ['--pretty=format:fugitive://'.s:repo().dir().'//%H'.path.'::'.g:fugitive_summary_format]
|
||||||
if empty(filter(a:000[0 : index(a:000,'--')],'v:val !~# "^-"'))
|
if empty(filter(a:000[0 : index(a:000,'--')],'v:val !~# "^-"'))
|
||||||
if s:buffer().commit() =~# '\x\{40\}'
|
let commit = s:DirCommitFile(@%)[1]
|
||||||
let cmd += [s:buffer().commit()]
|
if len(commit) > 2
|
||||||
|
let cmd += [commit]
|
||||||
elseif s:Relative('') =~# '^\.git/refs/\|^\.git/.*HEAD$'
|
elseif s:Relative('') =~# '^\.git/refs/\|^\.git/.*HEAD$'
|
||||||
let cmd += [s:Relative('')[5:-1]]
|
let cmd += [s:Relative('')[5:-1]]
|
||||||
endif
|
endif
|
||||||
@ -1658,7 +1659,7 @@ function! s:Edit(cmd, bang, mods, ...) abort
|
|||||||
let file = buffer.expand(join(a:000, ' '))
|
let file = buffer.expand(join(a:000, ' '))
|
||||||
elseif expand('%') ==# ''
|
elseif expand('%') ==# ''
|
||||||
let file = ':'
|
let file = ':'
|
||||||
elseif buffer.commit() ==# '' && s:Relative('/') !~# '^/.git\>'
|
elseif empty(s:DirCommitFile(@%)[1]) && s:Relative('/') !~# '^/.git\>'
|
||||||
let file = s:Relative(':')
|
let file = s:Relative(':')
|
||||||
else
|
else
|
||||||
let file = s:Relative('/')
|
let file = s:Relative('/')
|
||||||
@ -1739,7 +1740,7 @@ function! s:Write(force,...) abort
|
|||||||
if path =~# '^:\d\>'
|
if path =~# '^:\d\>'
|
||||||
return 'write'.(a:force ? '! ' : ' ').s:fnameescape(s:Generate(s:buffer().expand(path)))
|
return 'write'.(a:force ? '! ' : ' ').s:fnameescape(s:Generate(s:buffer().expand(path)))
|
||||||
endif
|
endif
|
||||||
let always_permitted = (s:Relative('') ==# path && s:buffer().commit() =~# '^0\=$')
|
let always_permitted = (s:Relative('') ==# path && s:DirCommitFile(@%)[1] =~# '^0\=$')
|
||||||
if !always_permitted && !a:force && (len(s:TreeChomp('diff','--name-status','HEAD','--',path)) || len(s:TreeChomp('ls-files','--others','--',path)))
|
if !always_permitted && !a:force && (len(s:TreeChomp('diff','--name-status','HEAD','--',path)) || len(s:TreeChomp('ls-files','--others','--',path)))
|
||||||
let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)'
|
let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)'
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
@ -1796,7 +1797,7 @@ function! s:Write(force,...) abort
|
|||||||
let v:errmsg = 'fugitive: '.error
|
let v:errmsg = 'fugitive: '.error
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
endif
|
endif
|
||||||
if s:Relative('') ==# path && s:buffer().commit() =~# '^\d$'
|
if s:Relative('') ==# path && s:DirCommitFile(@%)[1] =~# '^\d$'
|
||||||
set nomodified
|
set nomodified
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -2111,7 +2112,7 @@ function! s:Move(force, rename, destination) abort
|
|||||||
let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.')
|
let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.')
|
||||||
endif
|
endif
|
||||||
call fugitive#ReloadStatus()
|
call fugitive#ReloadStatus()
|
||||||
if empty(s:buffer().commit())
|
if empty(s:DirCommitFile(@%)[1])
|
||||||
if isdirectory(destination)
|
if isdirectory(destination)
|
||||||
return 'keepalt edit '.s:fnameescape(destination)
|
return 'keepalt edit '.s:fnameescape(destination)
|
||||||
else
|
else
|
||||||
@ -2140,9 +2141,9 @@ function! s:RenameComplete(A,L,P) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Remove(after, force) abort
|
function! s:Remove(after, force) abort
|
||||||
if s:buffer().commit() ==# ''
|
if s:DirCommitFile(@%)[1] ==# ''
|
||||||
let cmd = ['rm']
|
let cmd = ['rm']
|
||||||
elseif s:buffer().commit() ==# '0'
|
elseif s:DirCommitFile(@%)[1] ==# '0'
|
||||||
let cmd = ['rm','--cached']
|
let cmd = ['rm','--cached']
|
||||||
else
|
else
|
||||||
let v:errmsg = 'fugitive: rm not supported here'
|
let v:errmsg = 'fugitive: rm not supported here'
|
||||||
@ -2163,7 +2164,7 @@ endfunction
|
|||||||
|
|
||||||
augroup fugitive_remove
|
augroup fugitive_remove
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd User Fugitive if s:buffer().commit() =~# '^0\=$' |
|
autocmd User Fugitive if s:DirCommitFile(@%)[1] =~# '^0\=$' |
|
||||||
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:MoveComplete Gmove :execute s:Move(<bang>0,0,<q-args>)" |
|
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:MoveComplete Gmove :execute s:Move(<bang>0,0,<q-args>)" |
|
||||||
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:RenameComplete Grename :execute s:Move(<bang>0,1,<q-args>)" |
|
\ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:RenameComplete Grename :execute s:Move(<bang>0,1,<q-args>)" |
|
||||||
\ exe "command! -buffer -bar -bang Gremove :execute s:Remove('edit',<bang>0)" |
|
\ exe "command! -buffer -bar -bang Gremove :execute s:Remove('edit',<bang>0)" |
|
||||||
@ -2214,8 +2215,8 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
|||||||
endif
|
endif
|
||||||
call map(a:args,'s:sub(v:val,"^\\ze[^-]","-")')
|
call map(a:args,'s:sub(v:val,"^\\ze[^-]","-")')
|
||||||
let cmd = ['--no-pager', 'blame', '--show-number'] + a:args
|
let cmd = ['--no-pager', 'blame', '--show-number'] + a:args
|
||||||
if s:buffer().commit() =~# '\D\|..'
|
if s:DirCommitFile(@%)[1] =~# '\D\|..'
|
||||||
let cmd += [s:buffer().commit()]
|
let cmd += [s:DirCommitFile(@%)[1]]
|
||||||
else
|
else
|
||||||
let cmd += ['--contents', '-']
|
let cmd += ['--contents', '-']
|
||||||
endif
|
endif
|
||||||
@ -3011,10 +3012,11 @@ function! s:cfile() abort
|
|||||||
|
|
||||||
if buffer.type('tree')
|
if buffer.type('tree')
|
||||||
let showtree = (getline(1) =~# '^tree ' && getline(2) == "")
|
let showtree = (getline(1) =~# '^tree ' && getline(2) == "")
|
||||||
|
let base = s:DirCommitFile(@%)[1].':'.s:Relative('').(s:Relative('') =~# '^$\|/$' ? '' : '/')
|
||||||
if showtree && line('.') > 2
|
if showtree && line('.') > 2
|
||||||
return [buffer.commit().':'.s:Relative('').(s:Relative('') =~# '^$\|/$' ? '' : '/').s:sub(getline('.'),'/$','')]
|
return [base . s:sub(getline('.'),'/$','')]
|
||||||
elseif getline('.') =~# '^\d\{6\} \l\{3,8\} \x\{40\}\t'
|
elseif getline('.') =~# '^\d\{6\} \l\{3,8\} \x\{40\}\t'
|
||||||
return [buffer.commit().':'.s:Relative('').(s:Relative('') =~# '^$\|/$' ? '' : '/').s:sub(matchstr(getline('.'),'\t\zs.*'),'/$','')]
|
return [base . s:sub(matchstr(getline('.'),'\t\zs.*'),'/$','')]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
elseif buffer.type('blob')
|
elseif buffer.type('blob')
|
||||||
@ -3221,8 +3223,9 @@ function! fugitive#Statusline(...) abort
|
|||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
let status = ''
|
let status = ''
|
||||||
if s:buffer().commit() != ''
|
let commit = s:DirCommitFile(@%)[1]
|
||||||
let status .= ':' . s:buffer().commit()[0:7]
|
if len(commit)
|
||||||
|
let status .= ':' . commit[0:7]
|
||||||
endif
|
endif
|
||||||
let status .= '('.FugitiveHead(7).')'
|
let status .= '('.FugitiveHead(7).')'
|
||||||
if &statusline =~# '%[MRHWY]' && &statusline !~# '%[mrhwy]'
|
if &statusline =~# '%[MRHWY]' && &statusline !~# '%[mrhwy]'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user