9 Commits
v3.5 ... v3.6

Author SHA1 Message Date
Tim Pope
5a24c25275 fugitive.vim 3.6
* Fix support for older Vim 7 patch levels.
* Support copies on :Gclog --follow.
2021-11-25 14:53:57 -05:00
Tim Pope
e82332ee9e Try to avoid trailing newline blame issues
Resolves: https://github.com/tpope/vim-fugitive/issues/1892
2021-11-22 13:24:21 -05:00
Tim Pope
64bc1a3431 Remove dead code
The use of remove() here wouldn't actually work as it expects an index,
not a value.
2021-11-19 17:42:33 -05:00
Tim Pope
4a8db6b856 Support copies with :Gclog --follow
Resolves: https://github.com/tpope/vim-fugitive/issues/1891
2021-11-19 17:19:30 -05:00
Tim Pope
3d5d23fe80 Remove q map stubs
Resolves: https://github.com/tpope/vim-fugitive/issues/1890
2021-11-19 17:16:36 -05:00
Tim Pope
2dfaf17f9e Use dummy events to prevent "No matching autocommands" message
This list of events was hand-curated to eliminate events already defined
elsewhere in the autoload file.

Resolves: https://github.com/tpope/vim-fugitive/issues/1887
2021-11-16 16:09:59 -05:00
Tim Pope
69ae31d402 Fix command execution on Vim 7
This worked on my test environment of 7.4.888, but did not work on
7.4.000.

References: https://github.com/tpope/vim-fugitive/issues/1889
2021-11-16 13:44:55 -05:00
Tim Pope
f9c0b8eafe Fix readfile() usage
Resolves: https://github.com/tpope/vim-fugitive/issues/1886
2021-11-15 20:54:19 -05:00
Tim Pope
e47121f8fd Fix typo 2021-11-15 00:31:32 -05:00
2 changed files with 34 additions and 36 deletions

View File

@@ -341,12 +341,19 @@ function! s:JobExecute(argv, jopts, stdin, callback, ...) abort
let cmd = s:shellesc(a:argv) let cmd = s:shellesc(a:argv)
let outfile = tempname() let outfile = tempname()
try try
let dict.stderr = split(system(' (' . cmd . ' >' . outfile . ') ', join(a:stdin, "\n")), "\n", 1) if len(a:stdin)
call writefile(a:stdin, outfile . '.in', 'b')
let cmd = ' (' . cmd . ' >' . outfile . ' <' . outfile . '.in) '
else
let cmd = ' (' . cmd . ' >' . outfile . ') '
endif
let dict.stderr = split(system(cmd), "\n", 1)
let dict.exit_status = v:shell_error let dict.exit_status = v:shell_error
let dict.stdout = readfile(outfile, 'b') let dict.stdout = readfile(outfile, 'b')
call call(cb[0], [dict] + cb[1:-1]) call call(cb[0], [dict] + cb[1:-1])
finally finally
call delete(outfile) call delete(outfile)
call delete(outfile . '.in')
endtry endtry
endif endif
if empty(a:callback) if empty(a:callback)
@@ -474,7 +481,7 @@ function! fugitive#CommonDir(dir) abort
if getfsize(a:dir . '/HEAD') < 10 if getfsize(a:dir . '/HEAD') < 10
let s:commondirs[a:dir] = '' let s:commondirs[a:dir] = ''
elseif filereadable(a:dir . '/commondir') elseif filereadable(a:dir . '/commondir')
let cdir = get(readfile(a:dir . '/commondir', 1), 0, '') let cdir = get(readfile(a:dir . '/commondir', '', 1), 0, '')
if cdir =~# '^/\|^\a:/' if cdir =~# '^/\|^\a:/'
let s:commondirs[a:dir] = s:Slash(FugitiveVimPath(cdir)) let s:commondirs[a:dir] = s:Slash(FugitiveVimPath(cdir))
else else
@@ -1441,7 +1448,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) ab
let opts = {'title': a:title, 'context': {'items': []}} let opts = {'title': a:title, 'context': {'items': []}}
call s:QuickfixCreate(a:nr, opts) call s:QuickfixCreate(a:nr, opts)
let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event
silent exe s:DoAutocmd('QuickFixCmdPre ' . event) exe s:DoAutocmd('QuickFixCmdPre ' . event)
let winnr = winnr() let winnr = winnr()
exe s:QuickfixOpen(a:nr, a:mods) exe s:QuickfixOpen(a:nr, a:mods)
if winnr != winnr() if winnr != winnr()
@@ -1468,7 +1475,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) ab
lockvar opts.context.items lockvar opts.context.items
call s:QuickfixSet(a:nr, buffer, 'a') call s:QuickfixSet(a:nr, buffer, 'a')
silent exe s:DoAutocmd('QuickFixCmdPost ' . event) exe s:DoAutocmd('QuickFixCmdPost ' . event)
if a:first && len(s:QuickfixGet(a:nr)) if a:first && len(s:QuickfixGet(a:nr))
return (a:nr < 0 ? 'cfirst' : 'lfirst') return (a:nr < 0 ? 'cfirst' : 'lfirst')
else else
@@ -2480,6 +2487,9 @@ endfunction
augroup fugitive_dummy_events augroup fugitive_dummy_events
autocmd! autocmd!
autocmd User Fugitive* " autocmd User Fugitive* "
autocmd BufWritePre,FileWritePre,FileWritePost * "
autocmd BufNewFile * "
autocmd QuickfixCmdPre,QuickfixCmdPost * "
augroup END augroup END
function! s:ReplaceCmd(cmd) abort function! s:ReplaceCmd(cmd) abort
@@ -2586,7 +2596,7 @@ function! fugitive#BufReadStatus(...) abort
let amatch = s:Slash(expand('%:p')) let amatch = s:Slash(expand('%:p'))
unlet! b:fugitive_reltime b:fugitive_type unlet! b:fugitive_reltime b:fugitive_type
try try
silent doautocmd BufReadPre doautocmd BufReadPre
let config = fugitive#Config() let config = fugitive#Config()
let cmd = [fnamemodify(amatch, ':h')] let cmd = [fnamemodify(amatch, ':h')]
@@ -2835,7 +2845,7 @@ function! fugitive#BufReadStatus(...) abort
endif endif
setlocal nomodified readonly noswapfile setlocal nomodified readonly noswapfile
silent doautocmd BufReadPost doautocmd BufReadPost
setlocal nomodifiable setlocal nomodifiable
if &bufhidden ==# '' if &bufhidden ==# ''
setlocal bufhidden=delete setlocal bufhidden=delete
@@ -2879,9 +2889,6 @@ function! fugitive#BufReadStatus(...) abort
call s:Map('x', 'p', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') call s:Map('x', 'p', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>')
call s:Map('n', 'I', ":<C-U>execute <SID>StagePatch(line('.'),line('.'))<CR>", '<silent>') call s:Map('n', 'I', ":<C-U>execute <SID>StagePatch(line('.'),line('.'))<CR>", '<silent>')
call s:Map('x', 'I', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>') call s:Map('x', 'I', ":<C-U>execute <SID>StagePatch(line(\"'<\"),line(\"'>\"))<CR>", '<silent>')
if empty(mapcheck('q', 'n'))
nnoremap <buffer> <silent> q :<C-U>echoerr "fugitive: q is removed in favor of gq (or :q)"<CR>
endif
call s:Map('n', 'gq', ":<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>", '<silent>') call s:Map('n', 'gq', ":<C-U>if bufnr('$') == 1<Bar>quit<Bar>else<Bar>bdelete<Bar>endif<CR>", '<silent>')
call s:Map('n', 'R', ":echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>", '<silent>') call s:Map('n', 'R', ":echohl WarningMsg<Bar>echo 'Reloading is automatic. Use :e to force'<Bar>echohl NONE<CR>", '<silent>')
call s:Map('n', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>') call s:Map('n', 'g<Bar>', ":<C-U>echoerr 'Changed to X'<CR>", '<silent><unique>')
@@ -2998,10 +3005,10 @@ function! fugitive#BufReadCmd(...) abort
endif endif
if rev =~# '^:\d:' if rev =~# '^:\d:'
let &l:readonly = !filewritable(fugitive#Find('.git/index', dir)) let &l:readonly = !filewritable(fugitive#Find('.git/index', dir))
return 'silent doautocmd BufNewFile' return 'doautocmd BufNewFile'
else else
setlocal readonly nomodifiable setlocal readonly nomodifiable
return 'silent doautocmd BufNewFile|echo ' . string(error) return 'doautocmd BufNewFile|echo ' . string(error)
endif endif
elseif b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$' elseif b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$'
return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'") return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'")
@@ -3026,7 +3033,7 @@ function! fugitive#BufReadCmd(...) abort
if b:fugitive_type !=# 'blob' if b:fugitive_type !=# 'blob'
setlocal foldmarker=<<<<<<<<,>>>>>>>> setlocal foldmarker=<<<<<<<<,>>>>>>>>
endif endif
silent exe s:DoAutocmd('BufReadPre') exe s:DoAutocmd('BufReadPre')
if b:fugitive_type ==# 'tree' if b:fugitive_type ==# 'tree'
let b:fugitive_display_format = b:fugitive_display_format % 2 let b:fugitive_display_format = b:fugitive_display_format % 2
if b:fugitive_display_format if b:fugitive_display_format
@@ -3092,7 +3099,7 @@ function! fugitive#BufReadCmd(...) abort
setlocal modifiable setlocal modifiable
return 'silent ' . s:DoAutocmd('BufReadPost') . return s:DoAutocmd('BufReadPost') .
\ (modifiable ? '' : '|setl nomodifiable') . '|' . \ (modifiable ? '' : '|setl nomodifiable') . '|' .
\ call('s:DoAutocmd', events) \ call('s:DoAutocmd', events)
catch /^fugitive:/ catch /^fugitive:/
@@ -3201,9 +3208,6 @@ function! s:TempReadPost(file) abort
endif endif
setlocal foldmarker=<<<<<<<<,>>>>>>>> setlocal foldmarker=<<<<<<<<,>>>>>>>>
if !&modifiable if !&modifiable
if empty(mapcheck('q', 'n'))
nnoremap <buffer> <silent> q :<C-U>echoerr "fugitive: q is removed in favor of gq (or :q)"<CR>
endif
call s:Map('n', 'gq', ":<C-U>bdelete<CR>", '<silent> <unique>') call s:Map('n', 'gq', ":<C-U>bdelete<CR>", '<silent> <unique>')
endif endif
endif endif
@@ -5655,7 +5659,7 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
\ 'mods': s:Mods(a:mods), \ 'mods': s:Mods(a:mods),
\ 'file': s:Resolve(tempfile)} \ 'file': s:Resolve(tempfile)}
let event = listnr < 0 ? 'grep-fugitive' : 'lgrep-fugitive' let event = listnr < 0 ? 'grep-fugitive' : 'lgrep-fugitive'
silent exe s:DoAutocmd('QuickFixCmdPre ' . event) exe s:DoAutocmd('QuickFixCmdPre ' . event)
try try
if !quiet && &more if !quiet && &more
let more = 1 let more = 1
@@ -5679,7 +5683,7 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort
endif endif
endtry endtry
call s:RunFinished(state) call s:RunFinished(state)
silent exe s:DoAutocmd('QuickFixCmdPost ' . event) exe s:DoAutocmd('QuickFixCmdPost ' . event)
if quiet if quiet
let bufnr = bufnr('') let bufnr = bufnr('')
exe s:QuickfixOpen(listnr, a:mods) exe s:QuickfixOpen(listnr, a:mods)
@@ -5780,7 +5784,7 @@ function! s:LogParse(state, dir, prefix, line) abort
endif endif
elseif a:state.follow && elseif a:state.follow &&
\ a:line =~# '^ \%(mode change \d\|\%(create\|delete\) mode \d\|\%(rename\|copy\|rewrite\) .* (\d\+%)$\)' \ a:line =~# '^ \%(mode change \d\|\%(create\|delete\) mode \d\|\%(rename\|copy\|rewrite\) .* (\d\+%)$\)'
let rename = matchstr(a:line, '^ rename \zs.* => .*\ze (\d\+%)$') let rename = matchstr(a:line, '^ \%(copy\|rename\) \zs.* => .*\ze (\d\+%)$')
if len(rename) if len(rename)
let rename = rename =~# '{.* => .*}' ? rename : '{' . rename . '}' let rename = rename =~# '{.* => .*}' ? rename : '{' . rename . '}'
if a:state.target ==# simplify('/' . substitute(rename, '{.* => \(.*\)}', '\1', '')) if a:state.target ==# simplify('/' . substitute(rename, '{.* => \(.*\)}', '\1', ''))
@@ -6175,7 +6179,7 @@ function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, ...) abort
unlet! restorewinnr unlet! restorewinnr
let zero = fugitive#Find(':0:'.file) let zero = fugitive#Find(':0:'.file)
silent exe s:DoAutocmd('BufWritePost ' . s:fnameescape(zero)) exe s:DoAutocmd('BufWritePost ' . s:fnameescape(zero))
for tab in range(1,tabpagenr('$')) for tab in range(1,tabpagenr('$'))
for winnr in range(1,tabpagewinnr(tab,'$')) for winnr in range(1,tabpagewinnr(tab,'$'))
let bufnr = tabpagebuflist(tab)[winnr-1] let bufnr = tabpagebuflist(tab)[winnr-1]
@@ -6767,9 +6771,13 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
elseif empty(files) && len(matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$')) elseif empty(files) && len(matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$'))
let cmd += [matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$')] let cmd += [matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$')]
elseif empty(files) && !s:HasOpt(flags, '--reverse') elseif empty(files) && !s:HasOpt(flags, '--reverse')
let cmd += ['--contents', tempname . '.in'] if &modified
silent execute 'noautocmd keepalt %write ' . s:fnameescape(tempname . '.in') let cmd += ['--contents', tempname . '.in']
let delete_in = 1 silent execute 'noautocmd keepalt %write ' . s:fnameescape(tempname . '.in')
let delete_in = 1
elseif &autoread
exe 'checktime ' . bufnr('')
endif
else else
call fugitive#Autowrite() call fugitive#Autowrite()
endif endif
@@ -6979,13 +6987,6 @@ function! s:BlameJump(suffix, ...) abort
let offset = line('.') - line('w0') let offset = line('.') - line('w0')
let state = s:TempState() let state = s:TempState()
let flags = get(state, 'blame_flags', []) let flags = get(state, 'blame_flags', [])
if a:0 && a:1
if s:HasOpt(flags, '--reverse')
call remove(flags, '--reverse')
else
call add(flags, '--reverse')
endif
endif
let blame_bufnr = s:BlameBufnr() let blame_bufnr = s:BlameBufnr()
if blame_bufnr > 0 if blame_bufnr > 0
let bufnr = bufnr('') let bufnr = bufnr('')
@@ -7102,9 +7103,6 @@ function! s:BlameMaps(is_ftplugin) abort
let ft = a:is_ftplugin let ft = a:is_ftplugin
call s:Map('n', '<F1>', ':help :Git_blame<CR>', '<silent>', ft) call s:Map('n', '<F1>', ':help :Git_blame<CR>', '<silent>', ft)
call s:Map('n', 'g?', ':help :Git_blame<CR>', '<silent>', ft) call s:Map('n', 'g?', ':help :Git_blame<CR>', '<silent>', ft)
if empty(mapcheck('q', 'n'))
nnoremap <buffer> <silent> q :<C-U>echoerr "fugitive: q removed in favor of gq (or :q)"<CR>
endif
call s:Map('n', 'gq', ':exe <SID>BlameQuit()<CR>', '<silent>', ft) call s:Map('n', 'gq', ':exe <SID>BlameQuit()<CR>', '<silent>', ft)
call s:Map('n', '<2-LeftMouse>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft) call s:Map('n', '<2-LeftMouse>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft)
call s:Map('n', '<CR>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft) call s:Map('n', '<CR>', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft)

View File

@@ -1,6 +1,6 @@
" fugitive.vim - A Git wrapper so awesome, it should be illegal " fugitive.vim - A Git wrapper so awesome, it should be illegal
" Maintainer: Tim Pope <http://tpo.pe/> " Maintainer: Tim Pope <http://tpo.pe/>
" Version: 3.5 " Version: 3.6
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim " GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive') if exists('g:loaded_fugitive')
@@ -211,8 +211,8 @@ function! FugitiveRemoteUrl(...) abort
endfunction endfunction
" FugitiveRemote() returns a data structure parsed from the remote URL. " FugitiveRemote() returns a data structure parsed from the remote URL.
" For example, for remote URL is "https://me@example.com:1234/repo.git", " For example, for remote URL "https://me@example.com:1234/repo.git", the
" the returned dictionary will contain the following: " returned dictionary will contain the following:
" "
" * "scheme": "https" " * "scheme": "https"
" * "authority": "user@example.com:1234" " * "authority": "user@example.com:1234"