mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-11 12:53:52 -05:00
Require Vim 7.4 or newer
This renders a lot of other version checks inside the plugin obsolete, but I'm going to hold off on cleaning them up until I'm sure this change is permanent.
This commit is contained in:
@@ -82,8 +82,19 @@ function! s:throw(string) abort
|
|||||||
throw 'fugitive: '.a:string
|
throw 'fugitive: '.a:string
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:VersionCheck() abort
|
||||||
|
if v:version < 704
|
||||||
|
return 'return ' . string('echoerr "fugitive: Vim 7.4 or newer required"')
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:DirCheck(...) abort
|
function! s:DirCheck(...) abort
|
||||||
if !empty(a:0 ? s:Dir(a:1) : s:Dir())
|
let vcheck = s:VersionCheck()
|
||||||
|
if !empty(vcheck)
|
||||||
|
return vcheck
|
||||||
|
elseif !empty(a:0 ? s:Dir(a:1) : s:Dir())
|
||||||
return ''
|
return ''
|
||||||
elseif empty(bufname(''))
|
elseif empty(bufname(''))
|
||||||
return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"')
|
return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"')
|
||||||
@@ -2777,6 +2788,7 @@ for s:colortype in ['advice', 'branch', 'diff', 'grep', 'interactive', 'pager',
|
|||||||
endfor
|
endfor
|
||||||
unlet s:colortype
|
unlet s:colortype
|
||||||
function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
function! fugitive#Command(line1, line2, range, bang, mods, arg) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
let dir = s:Dir()
|
let dir = s:Dir()
|
||||||
let config = copy(fugitive#Config(dir))
|
let config = copy(fugitive#Config(dir))
|
||||||
let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir))
|
let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir))
|
||||||
@@ -4976,6 +4988,7 @@ endfunction
|
|||||||
|
|
||||||
let s:bang_edits = {'split': 'Git', 'vsplit': 'vert Git', 'tabedit': 'tab Git', 'pedit': 'Git!'}
|
let s:bang_edits = {'split': 'Git', 'vsplit': 'vert Git', 'tabedit': 'tab Git', 'pedit': 'Git!'}
|
||||||
function! fugitive#Open(cmd, bang, mods, arg, args) abort
|
function! fugitive#Open(cmd, bang, mods, arg, args) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
if a:bang
|
if a:bang
|
||||||
return 'echoerr ' . string(':G' . a:cmd . '! for temp buffer output has been replaced by :' . get(s:bang_edits, a:cmd, 'Git') . ' --paginate')
|
return 'echoerr ' . string(':G' . a:cmd . '! for temp buffer output has been replaced by :' . get(s:bang_edits, a:cmd, 'Git') . ' --paginate')
|
||||||
endif
|
endif
|
||||||
@@ -5024,6 +5037,7 @@ function! s:ReadExec(line1, count, range, mods, env, args, options) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort
|
function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
if a:bang
|
if a:bang
|
||||||
return 'echoerr ' . string(':Gread! for temp buffer output has been replaced by :{range}Git! --paginate')
|
return 'echoerr ' . string(':Gread! for temp buffer output has been replaced by :{range}Git! --paginate')
|
||||||
endif
|
endif
|
||||||
@@ -5058,6 +5072,7 @@ endfunction
|
|||||||
" Section: :Gwrite, :Gwq
|
" Section: :Gwrite, :Gwq
|
||||||
|
|
||||||
function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abort
|
function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG')) && empty(a:arg)
|
if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG')) && empty(a:arg)
|
||||||
return (empty($GIT_INDEX_FILE) ? 'write|bdelete' : 'wq') . (a:bang ? '!' : '')
|
return (empty($GIT_INDEX_FILE) ? 'write|bdelete' : 'wq') . (a:bang ? '!' : '')
|
||||||
elseif get(b:, 'fugitive_type', '') ==# 'index' && empty(a:arg)
|
elseif get(b:, 'fugitive_type', '') ==# 'index' && empty(a:arg)
|
||||||
@@ -5334,6 +5349,7 @@ function! s:IsConflicted() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort
|
function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
let args = s:ArgSplit(a:arg)
|
let args = s:ArgSplit(a:arg)
|
||||||
let post = ''
|
let post = ''
|
||||||
if get(args, 0) =~# '^+'
|
if get(args, 0) =~# '^+'
|
||||||
@@ -6109,6 +6125,7 @@ function! s:BrowserOpen(url, mods, echo_copy) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abort
|
function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abort
|
||||||
|
exe s:VersionCheck()
|
||||||
let dir = s:Dir()
|
let dir = s:Dir()
|
||||||
try
|
try
|
||||||
let arg = a:arg
|
let arg = a:arg
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ let g:loaded_fugitive = 1
|
|||||||
let s:bad_git_dir = '/$\|^fugitive:'
|
let s:bad_git_dir = '/$\|^fugitive:'
|
||||||
|
|
||||||
function! FugitiveGitDir(...) abort
|
function! FugitiveGitDir(...) abort
|
||||||
if !a:0 || type(a:1) == type(0) && a:1 < 0
|
if v:version < 704
|
||||||
|
return ''
|
||||||
|
elseif !a:0 || type(a:1) == type(0) && a:1 < 0
|
||||||
if exists('g:fugitive_event')
|
if exists('g:fugitive_event')
|
||||||
return g:fugitive_event
|
return g:fugitive_event
|
||||||
endif
|
endif
|
||||||
@@ -327,6 +329,9 @@ function! FugitiveExtractGitDir(path) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveDetect(path) abort
|
function! FugitiveDetect(path) abort
|
||||||
|
if v:version < 704
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
|
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
|
||||||
unlet b:git_dir
|
unlet b:git_dir
|
||||||
endif
|
endif
|
||||||
@@ -392,79 +397,6 @@ function! s:ProjectionistDetect() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if v:version + has('patch061') < 703
|
|
||||||
runtime! autoload/fugitive.vim
|
|
||||||
endif
|
|
||||||
let g:io_fugitive = {
|
|
||||||
\ 'simplify': function('fugitive#simplify'),
|
|
||||||
\ 'resolve': function('fugitive#resolve'),
|
|
||||||
\ 'getftime': function('fugitive#getftime'),
|
|
||||||
\ 'getfsize': function('fugitive#getfsize'),
|
|
||||||
\ 'getftype': function('fugitive#getftype'),
|
|
||||||
\ 'filereadable': function('fugitive#filereadable'),
|
|
||||||
\ 'filewritable': function('fugitive#filewritable'),
|
|
||||||
\ 'isdirectory': function('fugitive#isdirectory'),
|
|
||||||
\ 'getfperm': function('fugitive#getfperm'),
|
|
||||||
\ 'setfperm': function('fugitive#setfperm'),
|
|
||||||
\ 'readfile': function('fugitive#readfile'),
|
|
||||||
\ 'writefile': function('fugitive#writefile'),
|
|
||||||
\ 'glob': function('fugitive#glob'),
|
|
||||||
\ 'delete': function('fugitive#delete'),
|
|
||||||
\ 'Real': function('FugitiveReal')}
|
|
||||||
|
|
||||||
augroup fugitive
|
|
||||||
autocmd!
|
|
||||||
|
|
||||||
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('<amatch>:p'))
|
|
||||||
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<amatch>')), ':p'))
|
|
||||||
|
|
||||||
autocmd FileType git
|
|
||||||
\ call fugitive#MapCfile()
|
|
||||||
autocmd FileType gitcommit
|
|
||||||
\ call fugitive#MapCfile('fugitive#MessageCfile()')
|
|
||||||
autocmd FileType git,gitcommit
|
|
||||||
\ if &foldtext ==# 'foldtext()' |
|
|
||||||
\ setlocal foldtext=fugitive#Foldtext() |
|
|
||||||
\ endif
|
|
||||||
autocmd FileType fugitive
|
|
||||||
\ call fugitive#MapCfile('fugitive#StatusCfile()')
|
|
||||||
autocmd FileType gitrebase
|
|
||||||
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
|
|
||||||
\ if &l:includeexpr !~# 'Fugitive' |
|
|
||||||
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,\}$'' && len(FugitiveGitDir()) ? FugitiveFind(v:fname) : ' .
|
|
||||||
\ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') |
|
|
||||||
\ endif |
|
|
||||||
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='
|
|
||||||
|
|
||||||
autocmd BufReadCmd index{,.lock}
|
|
||||||
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
|
||||||
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
|
|
||||||
\ exe fugitive#BufReadStatus() |
|
|
||||||
\ elseif filereadable(expand('<amatch>')) |
|
|
||||||
\ silent doautocmd BufReadPre |
|
|
||||||
\ keepalt read <amatch> |
|
|
||||||
\ 1delete_ |
|
|
||||||
\ silent doautocmd BufReadPost |
|
|
||||||
\ else |
|
|
||||||
\ silent doautocmd BufNewFile |
|
|
||||||
\ endif
|
|
||||||
|
|
||||||
autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd() |
|
|
||||||
\ if &path =~# '^\.\%(,\|$\)' |
|
|
||||||
\ let &l:path = substitute(&path, '^\.,\=', '', '') |
|
|
||||||
\ endif
|
|
||||||
autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd()
|
|
||||||
autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd()
|
|
||||||
autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd()
|
|
||||||
if exists('##SourceCmd')
|
|
||||||
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
|
|
||||||
endif
|
|
||||||
|
|
||||||
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
|
||||||
|
|
||||||
autocmd User ProjectionistDetect call s:ProjectionistDetect()
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
let s:addr_other = has('patch-8.1.560') ? '-addr=other' : ''
|
let s:addr_other = has('patch-8.1.560') ? '-addr=other' : ''
|
||||||
let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
||||||
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
||||||
@@ -551,6 +483,80 @@ if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|||||||
\ '|if <bang>1|redraw!|endif|echohl WarningMSG|echo ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
|
\ '|if <bang>1|redraw!|endif|echohl WarningMSG|echo ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if v:version < 704
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:io_fugitive = {
|
||||||
|
\ 'simplify': function('fugitive#simplify'),
|
||||||
|
\ 'resolve': function('fugitive#resolve'),
|
||||||
|
\ 'getftime': function('fugitive#getftime'),
|
||||||
|
\ 'getfsize': function('fugitive#getfsize'),
|
||||||
|
\ 'getftype': function('fugitive#getftype'),
|
||||||
|
\ 'filereadable': function('fugitive#filereadable'),
|
||||||
|
\ 'filewritable': function('fugitive#filewritable'),
|
||||||
|
\ 'isdirectory': function('fugitive#isdirectory'),
|
||||||
|
\ 'getfperm': function('fugitive#getfperm'),
|
||||||
|
\ 'setfperm': function('fugitive#setfperm'),
|
||||||
|
\ 'readfile': function('fugitive#readfile'),
|
||||||
|
\ 'writefile': function('fugitive#writefile'),
|
||||||
|
\ 'glob': function('fugitive#glob'),
|
||||||
|
\ 'delete': function('fugitive#delete'),
|
||||||
|
\ 'Real': function('FugitiveReal')}
|
||||||
|
|
||||||
|
augroup fugitive
|
||||||
|
autocmd!
|
||||||
|
|
||||||
|
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('<amatch>:p'))
|
||||||
|
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<amatch>')), ':p'))
|
||||||
|
|
||||||
|
autocmd FileType git
|
||||||
|
\ call fugitive#MapCfile()
|
||||||
|
autocmd FileType gitcommit
|
||||||
|
\ call fugitive#MapCfile('fugitive#MessageCfile()')
|
||||||
|
autocmd FileType git,gitcommit
|
||||||
|
\ if &foldtext ==# 'foldtext()' |
|
||||||
|
\ setlocal foldtext=fugitive#Foldtext() |
|
||||||
|
\ endif
|
||||||
|
autocmd FileType fugitive
|
||||||
|
\ call fugitive#MapCfile('fugitive#StatusCfile()')
|
||||||
|
autocmd FileType gitrebase
|
||||||
|
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
|
||||||
|
\ if &l:includeexpr !~# 'Fugitive' |
|
||||||
|
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,\}$'' && len(FugitiveGitDir()) ? FugitiveFind(v:fname) : ' .
|
||||||
|
\ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') |
|
||||||
|
\ endif |
|
||||||
|
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='
|
||||||
|
|
||||||
|
autocmd BufReadCmd index{,.lock}
|
||||||
|
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
||||||
|
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
|
||||||
|
\ exe fugitive#BufReadStatus() |
|
||||||
|
\ elseif filereadable(expand('<amatch>')) |
|
||||||
|
\ silent doautocmd BufReadPre |
|
||||||
|
\ keepalt read <amatch> |
|
||||||
|
\ 1delete_ |
|
||||||
|
\ silent doautocmd BufReadPost |
|
||||||
|
\ else |
|
||||||
|
\ silent doautocmd BufNewFile |
|
||||||
|
\ endif
|
||||||
|
|
||||||
|
autocmd BufReadCmd fugitive://*//* exe fugitive#BufReadCmd() |
|
||||||
|
\ if &path =~# '^\.\%(,\|$\)' |
|
||||||
|
\ let &l:path = substitute(&path, '^\.,\=', '', '') |
|
||||||
|
\ endif
|
||||||
|
autocmd BufWriteCmd fugitive://*//[0-3]/* exe fugitive#BufWriteCmd()
|
||||||
|
autocmd FileReadCmd fugitive://*//* exe fugitive#FileReadCmd()
|
||||||
|
autocmd FileWriteCmd fugitive://*//[0-3]/* exe fugitive#FileWriteCmd()
|
||||||
|
if exists('##SourceCmd')
|
||||||
|
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
|
||||||
|
endif
|
||||||
|
|
||||||
|
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
||||||
|
|
||||||
|
autocmd User ProjectionistDetect call s:ProjectionistDetect()
|
||||||
|
augroup END
|
||||||
|
|
||||||
if get(g:, 'fugitive_no_maps')
|
if get(g:, 'fugitive_no_maps')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user