|
|
|
|
@@ -506,9 +506,9 @@ function! s:buffer_path(...) dict abort
|
|
|
|
|
let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*')
|
|
|
|
|
if rev != ''
|
|
|
|
|
let rev = s:sub(rev,'\w*','')
|
|
|
|
|
elseif self.spec()[0 : len(self.repo().dir())] ==# self.repo().dir() . '/'
|
|
|
|
|
elseif self.repo().bare()
|
|
|
|
|
let rev = '/.git'.self.spec()[strlen(self.repo().dir()) : -1]
|
|
|
|
|
elseif !self.repo().bare() && self.spec()[0 : len(self.repo().tree())] ==# self.repo().tree() . '/'
|
|
|
|
|
else
|
|
|
|
|
let rev = self.spec()[strlen(self.repo().tree()) : -1]
|
|
|
|
|
endif
|
|
|
|
|
return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '')
|
|
|
|
|
@@ -1066,7 +1066,7 @@ function! s:Log(cmd,...)
|
|
|
|
|
let dir = getcwd()
|
|
|
|
|
try
|
|
|
|
|
execute cd.'`=s:repo().tree()`'
|
|
|
|
|
let &grepprg = escape(call(s:repo().git_command,cmd,s:repo()),'%#')
|
|
|
|
|
let &grepprg = escape(call(s:repo().git_command,cmd,s:repo()),'%')
|
|
|
|
|
let &grepformat = '%f::%m'
|
|
|
|
|
exe a:cmd
|
|
|
|
|
finally
|
|
|
|
|
@@ -1551,6 +1551,7 @@ augroup fugitive_blame
|
|
|
|
|
autocmd FileType fugitiveblame setlocal nomodeline | if exists('b:git_dir') | let &l:keywordprg = s:repo().keywordprg() | endif
|
|
|
|
|
autocmd Syntax fugitiveblame call s:BlameSyntax()
|
|
|
|
|
autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(<bang>0,<line1>,<line2>,<count>,[<f-args>])" | endif
|
|
|
|
|
autocmd ColorScheme * call s:RehighlightBlame()
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
function! s:linechars(pattern)
|
|
|
|
|
@@ -1736,6 +1737,9 @@ function! s:BlameJump(suffix) abort
|
|
|
|
|
return ''
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
let s:load_time = localtime()
|
|
|
|
|
let s:hash_colors = {}
|
|
|
|
|
|
|
|
|
|
function! s:BlameSyntax() abort
|
|
|
|
|
let b:current_syntax = 'fugitiveblame'
|
|
|
|
|
let conceal = has('conceal') ? ' conceal' : ''
|
|
|
|
|
@@ -1754,7 +1758,7 @@ function! s:BlameSyntax() abort
|
|
|
|
|
syn match FugitiveblameNotCommittedYet "(\@<=Not Committed Yet\>" contained containedin=FugitiveblameAnnotation
|
|
|
|
|
hi def link FugitiveblameBoundary Keyword
|
|
|
|
|
hi def link FugitiveblameHash Identifier
|
|
|
|
|
hi def link FugitiveblameUncommitted Function
|
|
|
|
|
hi def link FugitiveblameUncommitted Ignore
|
|
|
|
|
hi def link FugitiveblameTime PreProc
|
|
|
|
|
hi def link FugitiveblameLineNumber Number
|
|
|
|
|
hi def link FugitiveblameOriginalFile String
|
|
|
|
|
@@ -1762,12 +1766,76 @@ function! s:BlameSyntax() abort
|
|
|
|
|
hi def link FugitiveblameShort FugitiveblameDelimiter
|
|
|
|
|
hi def link FugitiveblameDelimiter Delimiter
|
|
|
|
|
hi def link FugitiveblameNotCommittedYet Comment
|
|
|
|
|
call s:HighlightBlameDates()
|
|
|
|
|
|
|
|
|
|
for lnum in range(1, line('$'))
|
|
|
|
|
let match = matchlist(getline(lnum), '\<\(\d\d\d\d\)-\(\d\d\)-\(\d\d\).\(\d\d\):\(\d\d\):\(\d\d\) \([+-]\d\d\d\d\)\>')[0:7]
|
|
|
|
|
if !empty(match)
|
|
|
|
|
let age = s:load_time - call(s:function('s:unixtime'), match[1:7])
|
|
|
|
|
else
|
|
|
|
|
let match = matchlist(getline(lnum), '\<\(\d\+\) \([+-]\d\d\d\d\)\>')[0:2]
|
|
|
|
|
if !empty(match)
|
|
|
|
|
let age = s:load_time - match[1]
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
if exists('age') && exists('*log')
|
|
|
|
|
let staleness = age < 0 ? 0 : float2nr(ceil(log(1+age/86400)))
|
|
|
|
|
if staleness > 15 | let staleness = 15 | endif
|
|
|
|
|
exe 'syn match FugitiveblameTime'.staleness.' "\<'.match[0].'\>" contained containedin=FugitiveblameAnnotation'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
let hash = matchstr(getline(lnum), '^\^\=\zs\x\{6\}')
|
|
|
|
|
if hash ==# '' || hash ==# '000000'
|
|
|
|
|
continue
|
|
|
|
|
endif
|
|
|
|
|
if &t_Co > 16 && exists('*csapprox#per_component#Approximate') && !has_key(s:hash_colors, hash)
|
|
|
|
|
let [a, r, g, b; __] = map(matchlist(hash, '\(\x\x\)\(\x\x\)\(\x\x\)'), 'str2nr(v:val,16)')
|
|
|
|
|
let color = csapprox#per_component#Approximate(r, g, b)
|
|
|
|
|
if color == 16 && &background ==# 'dark'
|
|
|
|
|
let color = 8
|
|
|
|
|
endif
|
|
|
|
|
let s:hash_colors[hash] = ' ctermfg='.color
|
|
|
|
|
endif
|
|
|
|
|
exe 'syn match FugitiveblameHash'.hash.' "\%(^\^\=\)\@<='.hash.'\x\{1,34\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite'
|
|
|
|
|
exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.get(s:hash_colors, hash, '')
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:HighlightBlameDates() abort
|
|
|
|
|
for i in range(0, 15)
|
|
|
|
|
let shade = 0x11 * (&background == 'dark' ? 0xf - i : i)
|
|
|
|
|
if &t_Co > 16 && exists('*csapprox#per_component#Approximate')
|
|
|
|
|
let cterm = ' ctermfg='.csapprox#per_component#Approximate(shade, shade, shade)
|
|
|
|
|
else
|
|
|
|
|
let cterm = ''
|
|
|
|
|
endif
|
|
|
|
|
execute 'hi FugitiveblameTime'.i.' guifg=#'.repeat(printf('%02x', shade),3).cterm
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:RehighlightBlame() abort
|
|
|
|
|
call s:HighlightBlameDates()
|
|
|
|
|
for [hash, cterm] in items(s:hash_colors)
|
|
|
|
|
exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.cterm
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:unixtime(year,mon,day,hour,min,sec, ...) abort
|
|
|
|
|
let y = a:year + 4800 - (a:mon <= 2)
|
|
|
|
|
let m = a:mon + (a:mon <= 2 ? 9 : -3)
|
|
|
|
|
let jul = a:day + (153*m+2)/5 + 1461*y/4 - 32083
|
|
|
|
|
let days = jul - y/100 + y/400 + 38 - 2440588
|
|
|
|
|
|
|
|
|
|
let offset = a:0 ? a:1 : '0000'
|
|
|
|
|
let seconds = days * 86400 + a:hour * 3600 + a:min * 60 + a:sec
|
|
|
|
|
let seconds -= 3600 * matchstr(offset, '[+-]\=\d\d') - 60 * matchstr(offset, '\d\d$')
|
|
|
|
|
return seconds
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" }}}1
|
|
|
|
|
" Gbrowse {{{1
|
|
|
|
|
|
|
|
|
|
call s:command("-bar -bang -range -nargs=? -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
|
|
|
|
|
call s:command("-bar -bang -count=0 -nargs=? -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
|
|
|
|
|
|
|
|
|
|
function! s:Browse(bang,line1,count,...) abort
|
|
|
|
|
try
|
|
|
|
|
@@ -1849,7 +1917,7 @@ function! s:Browse(bang,line1,count,...) abort
|
|
|
|
|
|
|
|
|
|
let url = s:github_url(s:repo(),raw,rev,commit,path,type,a:line1,a:count)
|
|
|
|
|
if url == ''
|
|
|
|
|
let url = s:instaweb_url(s:repo(),rev,commit,path,type,a:count > 0 ? a:line1 : 0)
|
|
|
|
|
let url = s:instaweb_url(s:repo(),rev,commit,path,type,a:count ? a:line1 : 0)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if url == ''
|
|
|
|
|
@@ -1870,19 +1938,14 @@ endfunction
|
|
|
|
|
function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort
|
|
|
|
|
let path = a:path
|
|
|
|
|
let domain_pattern = 'github\.com'
|
|
|
|
|
let domains = exists('g:fugitive_github_domains') ? g:fugitive_github_domains : []
|
|
|
|
|
for domain in domains
|
|
|
|
|
let domain_pattern .= '\|' . escape(split(domain, '://')[-1], '.')
|
|
|
|
|
for domain in exists('g:fugitive_github_domains') ? g:fugitive_github_domains : []
|
|
|
|
|
let domain_pattern .= '\|' . escape(domain, '.')
|
|
|
|
|
endfor
|
|
|
|
|
let repo = matchstr(a:url,'^\%(https\=://\|git://\|git@\)\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$')
|
|
|
|
|
if repo ==# ''
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
if index(domains, 'http://' . matchstr(repo, '^[^:/]*')) >= 0
|
|
|
|
|
let root = 'http://' . s:sub(repo,':','/')
|
|
|
|
|
else
|
|
|
|
|
let root = 'https://' . s:sub(repo,':','/')
|
|
|
|
|
endif
|
|
|
|
|
let root = 'https://' . s:sub(repo,':','/')
|
|
|
|
|
if path =~# '^\.git/refs/heads/'
|
|
|
|
|
let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1]
|
|
|
|
|
if branch ==# ''
|
|
|
|
|
@@ -1912,9 +1975,9 @@ function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort
|
|
|
|
|
let url = s:sub(root . '/tree/' . commit . '/' . path,'/$','')
|
|
|
|
|
elseif a:type == 'blob'
|
|
|
|
|
let url = root . '/blob/' . commit . '/' . path
|
|
|
|
|
if a:line2 > 0 && a:line1 == a:line2
|
|
|
|
|
if a:line2 && a:line1 == a:line2
|
|
|
|
|
let url .= '#L' . a:line1
|
|
|
|
|
elseif a:line2 > 0
|
|
|
|
|
elseif a:line2
|
|
|
|
|
let url .= '#L' . a:line1 . '-' . a:line2
|
|
|
|
|
endif
|
|
|
|
|
elseif a:type == 'tag'
|
|
|
|
|
@@ -2053,8 +2116,7 @@ function! s:BufReadIndex()
|
|
|
|
|
nnoremap <buffer> <silent> cA :<C-U>Gcommit --amend --reuse-message=HEAD<CR>
|
|
|
|
|
nnoremap <buffer> <silent> ca :<C-U>Gcommit --amend<CR>
|
|
|
|
|
nnoremap <buffer> <silent> cc :<C-U>Gcommit<CR>
|
|
|
|
|
nnoremap <buffer> <silent> cva :<C-U>Gcommit --amend --verbose<CR>
|
|
|
|
|
nnoremap <buffer> <silent> cvc :<C-U>Gcommit --verbose<CR>
|
|
|
|
|
nnoremap <buffer> <silent> cv :<C-U>Gcommit -v<CR>
|
|
|
|
|
nnoremap <buffer> <silent> D :<C-U>execute <SID>StageDiff('Gvdiff')<CR>
|
|
|
|
|
nnoremap <buffer> <silent> dd :<C-U>execute <SID>StageDiff('Gvdiff')<CR>
|
|
|
|
|
nnoremap <buffer> <silent> dh :<C-U>execute <SID>StageDiff('Gsdiff')<CR>
|
|
|
|
|
@@ -2492,7 +2554,7 @@ function! fugitive#foldtext() abort
|
|
|
|
|
let [add, remove] = [-1, -1]
|
|
|
|
|
let filename = ''
|
|
|
|
|
for lnum in range(v:foldstart, v:foldend)
|
|
|
|
|
if filename ==# '' && getline(lnum) =~# '^[+-]\{3\} [abciow12]/'
|
|
|
|
|
if filename ==# '' && getline(lnum) =~# '^[+-]\{3\} [ab]/'
|
|
|
|
|
let filename = getline(lnum)[6:-1]
|
|
|
|
|
endif
|
|
|
|
|
if getline(lnum) =~# '^+'
|
|
|
|
|
@@ -2506,9 +2568,6 @@ function! fugitive#foldtext() abort
|
|
|
|
|
if filename ==# ''
|
|
|
|
|
let filename = matchstr(getline(v:foldstart), '^diff .\{-\} a/\zs.*\ze b/')
|
|
|
|
|
endif
|
|
|
|
|
if filename ==# ''
|
|
|
|
|
let filename = getline(v:foldstart)[5:-1]
|
|
|
|
|
endif
|
|
|
|
|
if exists('binary')
|
|
|
|
|
return 'Binary: '.filename
|
|
|
|
|
else
|
|
|
|
|
|