|
|
|
|
@@ -70,6 +70,10 @@ endfunction
|
|
|
|
|
|
|
|
|
|
let s:git_versions = {}
|
|
|
|
|
|
|
|
|
|
function! s:git_command() abort
|
|
|
|
|
return get(g:, 'fugitive_git_command', g:fugitive_git_executable)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! fugitive#git_version(...) abort
|
|
|
|
|
if !has_key(s:git_versions, g:fugitive_git_executable)
|
|
|
|
|
let s:git_versions[g:fugitive_git_executable] = matchstr(system(g:fugitive_git_executable.' --version'), "\\S\\+\n")
|
|
|
|
|
@@ -112,11 +116,6 @@ function! s:define_commands() abort
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
augroup fugitive_utility
|
|
|
|
|
autocmd!
|
|
|
|
|
autocmd User Fugitive call s:define_commands()
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
let s:abstract_prototype = {}
|
|
|
|
|
|
|
|
|
|
" Section: Initialization
|
|
|
|
|
@@ -132,7 +131,12 @@ function! fugitive#extract_git_dir(path) abort
|
|
|
|
|
if s:shellslash(a:path) =~# '^fugitive://.*//'
|
|
|
|
|
return matchstr(s:shellslash(a:path), '\C^fugitive://\zs.\{-\}\ze//')
|
|
|
|
|
endif
|
|
|
|
|
let root = s:shellslash(simplify(fnamemodify(a:path, ':p:s?[\/]$??')))
|
|
|
|
|
if isdirectory(a:path)
|
|
|
|
|
let path = fnamemodify(a:path, ':p:s?[\/]$??')
|
|
|
|
|
else
|
|
|
|
|
let path = fnamemodify(a:path, ':p:h:s?[\/]$??')
|
|
|
|
|
endif
|
|
|
|
|
let root = s:shellslash(resolve(path))
|
|
|
|
|
let previous = ""
|
|
|
|
|
while root !=# previous
|
|
|
|
|
if root =~# '\v^//%([^/]+/?)?$'
|
|
|
|
|
@@ -184,6 +188,9 @@ function! fugitive#detect(path) abort
|
|
|
|
|
let dir = fugitive#extract_git_dir(a:path)
|
|
|
|
|
if dir !=# ''
|
|
|
|
|
let b:git_dir = dir
|
|
|
|
|
if empty(fugitive#buffer().path())
|
|
|
|
|
silent! exe haslocaldir() ? 'lcd .' : 'cd .'
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
if exists('b:git_dir')
|
|
|
|
|
@@ -200,7 +207,7 @@ function! fugitive#detect(path) abort
|
|
|
|
|
nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR>
|
|
|
|
|
endif
|
|
|
|
|
let buffer = fugitive#buffer()
|
|
|
|
|
if expand('%:p') =~# '//'
|
|
|
|
|
if expand('%:p') =~# '://'
|
|
|
|
|
call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', ''))
|
|
|
|
|
endif
|
|
|
|
|
if stridx(buffer.getvar('&tags'), escape(b:git_dir, ', ')) == -1
|
|
|
|
|
@@ -213,6 +220,7 @@ function! fugitive#detect(path) abort
|
|
|
|
|
endif
|
|
|
|
|
try
|
|
|
|
|
let [save_mls, &modelines] = [&mls, 0]
|
|
|
|
|
call s:define_commands()
|
|
|
|
|
doautocmd User Fugitive
|
|
|
|
|
finally
|
|
|
|
|
let &mls = save_mls
|
|
|
|
|
@@ -271,6 +279,9 @@ function! s:configured_tree(git_dir) abort
|
|
|
|
|
endif
|
|
|
|
|
elseif filereadable(a:git_dir . '/gitdir')
|
|
|
|
|
let worktree = fnamemodify(readfile(a:git_dir . '/gitdir')[0], ':h')
|
|
|
|
|
if worktree ==# '.'
|
|
|
|
|
unlet! worktree
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
if exists('worktree')
|
|
|
|
|
let s:worktree_for_dir[a:git_dir] = worktree
|
|
|
|
|
@@ -287,6 +298,9 @@ endfunction
|
|
|
|
|
function! s:repo_tree(...) dict abort
|
|
|
|
|
if self.dir() =~# '/\.git$'
|
|
|
|
|
let dir = self.dir()[0:-6]
|
|
|
|
|
if dir !~# '/'
|
|
|
|
|
let dir .= '/'
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
let dir = s:configured_tree(self.git_dir)
|
|
|
|
|
endif
|
|
|
|
|
@@ -344,7 +358,7 @@ function! s:repo_translate(spec) dict abort
|
|
|
|
|
elseif filereadable(refs.'remotes/'.a:spec)
|
|
|
|
|
return refs.'remotes/'.a:spec
|
|
|
|
|
elseif filereadable(refs.'remotes/'.a:spec.'/HEAD')
|
|
|
|
|
return refs.'remotes/'.a:spec,'/HEAD'
|
|
|
|
|
return refs.'remotes/'.a:spec.'/HEAD'
|
|
|
|
|
else
|
|
|
|
|
try
|
|
|
|
|
let ref = self.rev_parse(matchstr(a:spec,'[^:]*'))
|
|
|
|
|
@@ -375,12 +389,14 @@ endfunction
|
|
|
|
|
call s:add_methods('repo',['dir','tree','bare','translate','head'])
|
|
|
|
|
|
|
|
|
|
function! s:repo_git_command(...) dict abort
|
|
|
|
|
let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir)
|
|
|
|
|
let git = s:git_command() . ' --git-dir='.s:shellesc(self.git_dir)
|
|
|
|
|
return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'')
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:repo_git_chomp(...) dict abort
|
|
|
|
|
return s:sub(system(call(self.git_command,a:000,self)),'\n$','')
|
|
|
|
|
let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir)
|
|
|
|
|
let output = git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'')
|
|
|
|
|
return s:sub(system(output),'\n$','')
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:repo_git_chomp_in_tree(...) dict abort
|
|
|
|
|
@@ -457,7 +473,7 @@ endfunction
|
|
|
|
|
call s:add_methods('repo',['dirglob','superglob'])
|
|
|
|
|
|
|
|
|
|
function! s:repo_config(conf) dict abort
|
|
|
|
|
return matchstr(system(s:repo().git_command('config').' '.a:conf),"[^\r\n]*")
|
|
|
|
|
return matchstr(s:repo().git_chomp('config',a:conf),"[^\r\n]*")
|
|
|
|
|
endfun
|
|
|
|
|
|
|
|
|
|
function! s:repo_user() dict abort
|
|
|
|
|
@@ -469,8 +485,8 @@ endfun
|
|
|
|
|
function! s:repo_aliases() dict abort
|
|
|
|
|
if !has_key(self,'_aliases')
|
|
|
|
|
let self._aliases = {}
|
|
|
|
|
for line in split(self.git_chomp('config','--get-regexp','^alias[.]'),"\n")
|
|
|
|
|
let self._aliases[matchstr(line,'\.\zs\S\+')] = matchstr(line,' \zs.*')
|
|
|
|
|
for line in split(self.git_chomp('config','-z','--get-regexp','^alias[.]'),"\1")
|
|
|
|
|
let self._aliases[matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*')
|
|
|
|
|
endfor
|
|
|
|
|
endif
|
|
|
|
|
return self._aliases
|
|
|
|
|
@@ -481,9 +497,9 @@ call s:add_methods('repo',['config', 'user', 'aliases'])
|
|
|
|
|
function! s:repo_keywordprg() dict abort
|
|
|
|
|
let args = ' --git-dir='.escape(self.dir(),"\\\"' ")
|
|
|
|
|
if has('gui_running') && !has('win32')
|
|
|
|
|
return g:fugitive_git_executable . ' --no-pager' . args . ' log -1'
|
|
|
|
|
return s:git_command() . ' --no-pager' . args . ' log -1'
|
|
|
|
|
else
|
|
|
|
|
return g:fugitive_git_executable . args . ' show'
|
|
|
|
|
return s:git_command() . args . ' show'
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
@@ -694,14 +710,18 @@ function! s:Git(bang, args) abort
|
|
|
|
|
if a:bang
|
|
|
|
|
return s:Edit('edit', 1, a:args)
|
|
|
|
|
endif
|
|
|
|
|
let git = g:fugitive_git_executable
|
|
|
|
|
let git = s:git_command()
|
|
|
|
|
if has('gui_running') && !has('win32')
|
|
|
|
|
let git .= ' --no-pager'
|
|
|
|
|
endif
|
|
|
|
|
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
|
|
|
|
|
if exists(':terminal')
|
|
|
|
|
let dir = s:repo().tree()
|
|
|
|
|
tabedit %
|
|
|
|
|
if expand('%') != ''
|
|
|
|
|
-tabedit %
|
|
|
|
|
else
|
|
|
|
|
-tabnew
|
|
|
|
|
endif
|
|
|
|
|
execute 'lcd' fnameescape(dir)
|
|
|
|
|
execute 'terminal' git args
|
|
|
|
|
else
|
|
|
|
|
@@ -860,7 +880,9 @@ function! s:StageUndo() abort
|
|
|
|
|
let hash = repo.git_chomp('hash-object', '-w', filename)
|
|
|
|
|
if !empty(hash)
|
|
|
|
|
if section ==# 'untracked'
|
|
|
|
|
call delete(s:repo().tree(filename))
|
|
|
|
|
call repo.git_chomp_in_tree('clean', '-f', '--', filename)
|
|
|
|
|
elseif section ==# 'unmerged'
|
|
|
|
|
call repo.git_chomp_in_tree('rm', '--', filename)
|
|
|
|
|
elseif section ==# 'unstaged'
|
|
|
|
|
call repo.git_chomp_in_tree('checkout', '--', filename)
|
|
|
|
|
else
|
|
|
|
|
@@ -1055,13 +1077,14 @@ function! s:Commit(args, ...) abort
|
|
|
|
|
else
|
|
|
|
|
noautocmd silent execute '!'.command.' > '.outfile.' 2> '.errorfile
|
|
|
|
|
endif
|
|
|
|
|
let error = v:shell_error
|
|
|
|
|
finally
|
|
|
|
|
execute cd.'`=dir`'
|
|
|
|
|
endtry
|
|
|
|
|
if !has('gui_running')
|
|
|
|
|
redraw!
|
|
|
|
|
endif
|
|
|
|
|
if !v:shell_error
|
|
|
|
|
if !error
|
|
|
|
|
if filereadable(outfile)
|
|
|
|
|
for line in readfile(outfile)
|
|
|
|
|
echo line
|
|
|
|
|
@@ -1084,7 +1107,7 @@ function! s:Commit(args, ...) abort
|
|
|
|
|
if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod
|
|
|
|
|
execute 'keepalt edit '.s:fnameescape(msgfile)
|
|
|
|
|
elseif a:args =~# '\%(^\| \)-\%(-verbose\|\w*v\)\>'
|
|
|
|
|
execute 'keepalt '.(tabpagenr()-1).'tabedit '.s:fnameescape(msgfile)
|
|
|
|
|
execute 'keepalt -tabedit '.s:fnameescape(msgfile)
|
|
|
|
|
elseif s:buffer().type() ==# 'index'
|
|
|
|
|
execute 'keepalt edit '.s:fnameescape(msgfile)
|
|
|
|
|
execute (search('^#','n')+1).'wincmd+'
|
|
|
|
|
@@ -1115,7 +1138,7 @@ endfunction
|
|
|
|
|
|
|
|
|
|
function! s:CommitComplete(A,L,P) abort
|
|
|
|
|
if a:A =~ '^-' || type(a:A) == type(0) " a:A is 0 on :Gcommit -<Tab>
|
|
|
|
|
let args = ['-C', '-F', '-a', '-c', '-e', '-i', '-m', '-n', '-o', '-q', '-s', '-t', '-u', '-v', '--all', '--allow-empty', '--amend', '--author=', '--cleanup=', '--dry-run', '--edit', '--file=', '--include', '--interactive', '--message=', '--no-verify', '--only', '--quiet', '--reedit-message=', '--reuse-message=', '--signoff', '--template=', '--untracked-files', '--verbose']
|
|
|
|
|
let args = ['-C', '-F', '-a', '-c', '-e', '-i', '-m', '-n', '-o', '-q', '-s', '-t', '-u', '-v', '--all', '--allow-empty', '--amend', '--author=', '--cleanup=', '--dry-run', '--edit', '--file=', '--fixup=', '--include', '--interactive', '--message=', '--no-verify', '--only', '--quiet', '--reedit-message=', '--reuse-message=', '--signoff', '--squash=', '--template=', '--untracked-files', '--verbose']
|
|
|
|
|
return filter(args,'v:val[0 : strlen(a:A)-1] ==# a:A')
|
|
|
|
|
else
|
|
|
|
|
return s:repo().superglob(a:A)
|
|
|
|
|
@@ -1205,7 +1228,7 @@ function! s:Merge(cmd, bang, args) abort
|
|
|
|
|
\ !empty(s:repo().git_chomp('diff-files', '--diff-filter=U')))
|
|
|
|
|
let &l:makeprg = g:fugitive_git_executable.' diff-files --name-status --diff-filter=U'
|
|
|
|
|
else
|
|
|
|
|
let &l:makeprg = s:sub(g:fugitive_git_executable . ' ' . a:cmd .
|
|
|
|
|
let &l:makeprg = s:sub(s:git_command() . ' ' . a:cmd .
|
|
|
|
|
\ (a:args =~# ' \%(--no-edit\|--abort\|-m\)\>' ? '' : ' --edit') .
|
|
|
|
|
\ ' ' . a:args, ' *$', '')
|
|
|
|
|
endif
|
|
|
|
|
@@ -1384,6 +1407,9 @@ function! s:Edit(cmd,bang,...) abort
|
|
|
|
|
return 'redraw|echo '.string(':!'.git.' '.args)
|
|
|
|
|
else
|
|
|
|
|
let temp = resolve(tempname())
|
|
|
|
|
if has('win32')
|
|
|
|
|
let temp = fnamemodify(fnamemodify(temp, ':h'), ':p').fnamemodify(temp, ':t')
|
|
|
|
|
endif
|
|
|
|
|
let s:temp_files[s:cpath(temp)] = { 'dir': buffer.repo().dir(), 'args': arglist }
|
|
|
|
|
silent execute a:cmd.' '.temp
|
|
|
|
|
if a:cmd =~# 'pedit'
|
|
|
|
|
@@ -1563,6 +1589,7 @@ function! s:Write(force,...) abort
|
|
|
|
|
|
|
|
|
|
unlet! restorewinnr
|
|
|
|
|
let zero = s:repo().translate(':0:'.path)
|
|
|
|
|
silent execute 'doautocmd BufWritePost' s:fnameescape(zero)
|
|
|
|
|
for tab in range(1,tabpagenr('$'))
|
|
|
|
|
for winnr in range(1,tabpagewinnr(tab,'$'))
|
|
|
|
|
let bufnr = tabpagebuflist(tab)[winnr-1]
|
|
|
|
|
@@ -1625,7 +1652,7 @@ function! s:Dispatch(bang, args)
|
|
|
|
|
try
|
|
|
|
|
let b:current_compiler = 'git'
|
|
|
|
|
let &l:errorformat = s:common_efm
|
|
|
|
|
let &l:makeprg = g:fugitive_git_executable . ' ' . a:args
|
|
|
|
|
let &l:makeprg = substitute(s:git_command() . ' ' . a:args, '\s\+$', '', '')
|
|
|
|
|
execute cd fnameescape(s:repo().tree())
|
|
|
|
|
if exists(':Make') == 2
|
|
|
|
|
noautocmd Make
|
|
|
|
|
@@ -1774,13 +1801,17 @@ function! s:Diff(vert,keepfocus,...) abort
|
|
|
|
|
let nr = bufnr('')
|
|
|
|
|
execute 'leftabove '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`'
|
|
|
|
|
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
|
|
|
|
|
let nr2 = bufnr('')
|
|
|
|
|
call s:diffthis()
|
|
|
|
|
wincmd p
|
|
|
|
|
execute 'rightbelow '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
|
|
|
|
|
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
|
|
|
|
|
let nr3 = bufnr('')
|
|
|
|
|
call s:diffthis()
|
|
|
|
|
wincmd p
|
|
|
|
|
call s:diffthis()
|
|
|
|
|
execute 'nnoremap <buffer> <silent> d2o :diffget '.nr2.'<Bar>diffupdate<CR>'
|
|
|
|
|
execute 'nnoremap <buffer> <silent> d3o :diffget '.nr3.'<Bar>diffupdate<CR>'
|
|
|
|
|
return post
|
|
|
|
|
elseif len(args)
|
|
|
|
|
let arg = join(args, ' ')
|
|
|
|
|
@@ -2000,6 +2031,9 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
|
|
|
|
endif
|
|
|
|
|
let top = line('w0') + &scrolloff
|
|
|
|
|
let current = line('.')
|
|
|
|
|
if has('win32')
|
|
|
|
|
let temp = fnamemodify(fnamemodify(temp, ':h'), ':p').fnamemodify(temp, ':t')
|
|
|
|
|
endif
|
|
|
|
|
let s:temp_files[s:cpath(temp)] = { 'dir': s:repo().dir(), 'args': cmd }
|
|
|
|
|
exe 'keepalt leftabove vsplit '.temp
|
|
|
|
|
let b:fugitive_blamed_bufnr = bufnr
|
|
|
|
|
@@ -2018,6 +2052,7 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
|
|
|
|
if exists('+relativenumber')
|
|
|
|
|
setlocal norelativenumber
|
|
|
|
|
endif
|
|
|
|
|
let &l:statusline = '%{fugitive#blame_statusline('.bufnr('').')}%<'
|
|
|
|
|
execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1)
|
|
|
|
|
nnoremap <buffer> <silent> <F1> :help fugitive-:Gblame<CR>
|
|
|
|
|
nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR>
|
|
|
|
|
@@ -2177,7 +2212,7 @@ endfunction
|
|
|
|
|
|
|
|
|
|
function! s:RehighlightBlame() abort
|
|
|
|
|
for [hash, cterm] in items(s:hash_colors)
|
|
|
|
|
if !empty(cterm) || has('gui_running')
|
|
|
|
|
if !empty(cterm) || has('gui_running') || has('termguicolors') && &termguicolors
|
|
|
|
|
exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.get(s:hash_colors, hash, '')
|
|
|
|
|
else
|
|
|
|
|
exe 'hi link FugitiveblameHash'.hash.' Identifier'
|
|
|
|
|
@@ -2185,6 +2220,25 @@ function! s:RehighlightBlame() abort
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! fugitive#blame_statusline(nr) abort
|
|
|
|
|
if bufnr('%') != a:nr && !getwinvar(0, '&cursorbind')
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
let line = getbufline(a:nr, line('.'))[0]
|
|
|
|
|
let hash = matchstr(line, '^\^\=\zs\x\{7}')
|
|
|
|
|
if hash =~# '^0*$'
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
if type(getbufvar(a:nr, 'fugitive_blame_lookup')) != type({})
|
|
|
|
|
call setbufvar(a:nr, 'fugitive_blame_lookup', {})
|
|
|
|
|
endif
|
|
|
|
|
let lookup = getbufvar(a:nr, 'fugitive_blame_lookup')
|
|
|
|
|
if !has_key(lookup, hash)
|
|
|
|
|
let lookup[hash] = s:repo().git_chomp('log', '-1', hash, '--pretty=format:'.g:fugitive_summary_format)
|
|
|
|
|
endif
|
|
|
|
|
return get(lookup, hash, '')
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" Section: Gbrowse
|
|
|
|
|
|
|
|
|
|
call s:command("-bar -bang -range=0 -nargs=* -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
|
|
|
|
|
@@ -2249,10 +2303,11 @@ function! s:Browse(bang,line1,count,...) abort
|
|
|
|
|
if path =~# '^\.git/refs/remotes/.'
|
|
|
|
|
if empty(remote)
|
|
|
|
|
let remote = matchstr(path, '^\.git/refs/remotes/\zs[^/]\+')
|
|
|
|
|
let branch = matchstr(path, '^\.git/refs/remotes/[^/]\+/\zs.\+')
|
|
|
|
|
else
|
|
|
|
|
let merge = matchstr(path, '^\.git/refs/remotes/[^/]\+/\zs.\+')
|
|
|
|
|
let path = '.git/refs/heads/'.merge
|
|
|
|
|
endif
|
|
|
|
|
let merge = matchstr(path, '^\.git/refs/remotes/[^/]\+/\zs.\+')
|
|
|
|
|
let branch = ''
|
|
|
|
|
let path = '.git/refs/heads/'.merge
|
|
|
|
|
elseif path =~# '^\.git/refs/heads/.'
|
|
|
|
|
let branch = path[16:-1]
|
|
|
|
|
elseif !exists('branch')
|
|
|
|
|
@@ -2289,9 +2344,14 @@ function! s:Browse(bang,line1,count,...) abort
|
|
|
|
|
|
|
|
|
|
if empty(remote)
|
|
|
|
|
let remote = '.'
|
|
|
|
|
let raw = s:repo().git_chomp('config','remote.origin.url')
|
|
|
|
|
let remote_for_url = 'origin'
|
|
|
|
|
else
|
|
|
|
|
let raw = s:repo().git_chomp('config','remote.'.remote.'.url')
|
|
|
|
|
let remote_for_url = remote
|
|
|
|
|
endif
|
|
|
|
|
if fugitive#git_version() =~# '^[01]\.|^2\.[0-6]\.'
|
|
|
|
|
let raw = s:repo().git_chomp('config','remote.'.remote_for_url.'.url')
|
|
|
|
|
else
|
|
|
|
|
let raw = s:repo().git_chomp('remote','get-url',remote_for_url)
|
|
|
|
|
endif
|
|
|
|
|
if raw ==# ''
|
|
|
|
|
let raw = remote
|
|
|
|
|
@@ -2315,13 +2375,13 @@ function! s:Browse(bang,line1,count,...) abort
|
|
|
|
|
if empty(url) && raw ==# '.'
|
|
|
|
|
call s:throw("Instaweb failed to start")
|
|
|
|
|
elseif empty(url)
|
|
|
|
|
call s:throw('"'.remote."' is not a supported remote")
|
|
|
|
|
call s:throw("'".remote."' is not a supported remote")
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))')
|
|
|
|
|
if a:bang
|
|
|
|
|
if has('clipboard')
|
|
|
|
|
let @* = url
|
|
|
|
|
let @+ = url
|
|
|
|
|
endif
|
|
|
|
|
return 'echomsg '.string(url)
|
|
|
|
|
elseif exists(':Browse') == 2
|
|
|
|
|
@@ -2354,46 +2414,8 @@ function! s:github_url(opts, ...) abort
|
|
|
|
|
if repo ==# ''
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
let path = substitute(a:opts.path, '^/', '', '')
|
|
|
|
|
if index(domains, 'http://' . matchstr(repo, '^[^:/]*')) >= 0
|
|
|
|
|
let root = 'http://' . s:sub(repo,':','/')
|
|
|
|
|
else
|
|
|
|
|
let root = 'https://' . s:sub(repo,':','/')
|
|
|
|
|
endif
|
|
|
|
|
if path =~# '^\.git/refs/heads/'
|
|
|
|
|
let branch = a:opts.repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1]
|
|
|
|
|
if branch ==# ''
|
|
|
|
|
return root . '/commits/' . path[16:-1]
|
|
|
|
|
else
|
|
|
|
|
return root . '/commits/' . branch
|
|
|
|
|
endif
|
|
|
|
|
elseif path =~# '^\.git/refs/tags/'
|
|
|
|
|
return root . '/releases/tag/' . path[15:-1]
|
|
|
|
|
elseif path =~# '^\.git/refs/remotes/[^/]\+/.'
|
|
|
|
|
return root . '/commits/' . matchstr(path,'remotes/[^/]\+/\zs.*')
|
|
|
|
|
elseif path =~# '.git/\%(config$\|hooks\>\)'
|
|
|
|
|
return root . '/admin'
|
|
|
|
|
elseif path =~# '^\.git\>'
|
|
|
|
|
return root
|
|
|
|
|
endif
|
|
|
|
|
if a:opts.commit =~# '^\d\=$'
|
|
|
|
|
let commit = a:opts.repo.rev_parse('HEAD')
|
|
|
|
|
else
|
|
|
|
|
let commit = a:opts.commit
|
|
|
|
|
endif
|
|
|
|
|
if get(a:opts, 'type', '') ==# 'tree' || a:opts.path =~# '/$'
|
|
|
|
|
let url = substitute(root . '/tree/' . commit . '/' . path, '/$', '', 'g')
|
|
|
|
|
elseif get(a:opts, 'type', '') ==# 'blob' || a:opts.path =~# '[^/]$'
|
|
|
|
|
let url = root . '/blob/' . commit . '/' . path
|
|
|
|
|
if get(a:opts, 'line2') && a:opts.line1 == a:opts.line2
|
|
|
|
|
let url .= '#L' . a:opts.line1
|
|
|
|
|
elseif get(a:opts, 'line2')
|
|
|
|
|
let url .= '#L' . a:opts.line1 . '-L' . a:opts.line2
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
let url = root . '/commit/' . commit
|
|
|
|
|
endif
|
|
|
|
|
return url
|
|
|
|
|
call s:warn('Install rhubarb.vim for GitHub support')
|
|
|
|
|
return 'https://github.com/tpope/vim-rhubarb'
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! s:instaweb_url(opts) abort
|
|
|
|
|
@@ -2651,7 +2673,7 @@ function! s:BufReadObject() abort
|
|
|
|
|
let b:fugitive_type = s:repo().git_chomp('cat-file','-t',hash)
|
|
|
|
|
endif
|
|
|
|
|
if b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$'
|
|
|
|
|
return "echoerr 'fugitive: unrecognized git type'"
|
|
|
|
|
return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'")
|
|
|
|
|
endif
|
|
|
|
|
let firstline = getline('.')
|
|
|
|
|
if !exists('b:fugitive_display_format') && b:fugitive_type != 'blob'
|
|
|
|
|
@@ -2686,7 +2708,7 @@ function! s:BufReadObject() abort
|
|
|
|
|
if b:fugitive_display_format
|
|
|
|
|
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
|
|
|
|
|
else
|
|
|
|
|
call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree %T%nparent %P%nauthor %an <%ae> %ad%ncommitter %cn <%ce> %cd%nencoding %e%n%n%s%n%n%b',hash))
|
|
|
|
|
call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b',hash))
|
|
|
|
|
keepjumps call search('^parent ')
|
|
|
|
|
if getline('.') ==# 'parent '
|
|
|
|
|
silent keepjumps delete_
|
|
|
|
|
@@ -2838,7 +2860,7 @@ function! s:cfile() abort
|
|
|
|
|
elseif getline('.') =~# '^#\trenamed:.* -> '
|
|
|
|
|
let file = '/'.matchstr(getline('.'),' -> \zs.*')
|
|
|
|
|
return [file]
|
|
|
|
|
elseif getline('.') =~# '^#\t[[:alpha:] ]\+: *.'
|
|
|
|
|
elseif getline('.') =~# '^#\t\(\k\| \)\+\p\?: *.'
|
|
|
|
|
let file = '/'.matchstr(getline('.'),': *\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$')
|
|
|
|
|
return [file]
|
|
|
|
|
elseif getline('.') =~# '^#\t.'
|
|
|
|
|
@@ -2895,7 +2917,7 @@ function! s:cfile() abort
|
|
|
|
|
let ref = matchstr(getline('.'),'\x\{40\}')
|
|
|
|
|
echoerr "warning: unknown context ".matchstr(getline('.'),'^\l*')
|
|
|
|
|
|
|
|
|
|
elseif getline('.') =~# '^[+-]\{3\} [ab/]'
|
|
|
|
|
elseif getline('.') =~# '^[+-]\{3\} [abciow12]\=/'
|
|
|
|
|
let ref = getline('.')[4:]
|
|
|
|
|
|
|
|
|
|
elseif getline('.') =~# '^[+-]' && search('^@@ -\d\+,\d\+ +\d\+,','bnW')
|
|
|
|
|
@@ -2909,7 +2931,7 @@ function! s:cfile() abort
|
|
|
|
|
let lnum -= 1
|
|
|
|
|
endwhile
|
|
|
|
|
let offset += matchstr(getline(lnum), type.'\zs\d\+')
|
|
|
|
|
let ref = getline(search('^'.type.'\{3\} [ab]/','bnW'))[4:-1]
|
|
|
|
|
let ref = getline(search('^'.type.'\{3\} [abciow12]/','bnW'))[4:-1]
|
|
|
|
|
let dcmds = [offset, 'normal!zv']
|
|
|
|
|
|
|
|
|
|
elseif getline('.') =~# '^rename from '
|
|
|
|
|
@@ -2918,22 +2940,22 @@ function! s:cfile() abort
|
|
|
|
|
let ref = 'b/'.getline('.')[10:]
|
|
|
|
|
|
|
|
|
|
elseif getline('.') =~# '^@@ -\d\+,\d\+ +\d\+,'
|
|
|
|
|
let diff = getline(search('^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)', 'bcnW'))
|
|
|
|
|
let diff = getline(search('^diff --git \%([abciow12]/.*\|/dev/null\) \%([abciow12]/.*\|/dev/null\)', 'bcnW'))
|
|
|
|
|
let offset = matchstr(getline('.'), '+\zs\d\+')
|
|
|
|
|
|
|
|
|
|
let dref = matchstr(diff, '\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)')
|
|
|
|
|
let ref = matchstr(diff, '\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)')
|
|
|
|
|
let dref = matchstr(diff, '\Cdiff --git \zs\%([abciow12]/.*\|/dev/null\)\ze \%([abciow12]/.*\|/dev/null\)')
|
|
|
|
|
let ref = matchstr(diff, '\Cdiff --git \%([abciow12]/.*\|/dev/null\) \zs\%([abciow12]/.*\|/dev/null\)')
|
|
|
|
|
let dcmd = 'Gdiff! +'.offset
|
|
|
|
|
|
|
|
|
|
elseif getline('.') =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)'
|
|
|
|
|
let dref = matchstr(getline('.'),'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)')
|
|
|
|
|
let ref = matchstr(getline('.'),'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)')
|
|
|
|
|
elseif getline('.') =~# '^diff --git \%([abciow12]/.*\|/dev/null\) \%([abciow12]/.*\|/dev/null\)'
|
|
|
|
|
let dref = matchstr(getline('.'),'\Cdiff --git \zs\%([abciow12]/.*\|/dev/null\)\ze \%([abciow12]/.*\|/dev/null\)')
|
|
|
|
|
let ref = matchstr(getline('.'),'\Cdiff --git \%([abciow12]/.*\|/dev/null\) \zs\%([abciow12]/.*\|/dev/null\)')
|
|
|
|
|
let dcmd = 'Gdiff!'
|
|
|
|
|
|
|
|
|
|
elseif getline('.') =~# '^index ' && getline(line('.')-1) =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)'
|
|
|
|
|
elseif getline('.') =~# '^index ' && getline(line('.')-1) =~# '^diff --git \%([abciow12]/.*\|/dev/null\) \%([abciow12]/.*\|/dev/null\)'
|
|
|
|
|
let line = getline(line('.')-1)
|
|
|
|
|
let dref = matchstr(line,'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)')
|
|
|
|
|
let ref = matchstr(line,'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)')
|
|
|
|
|
let dref = matchstr(line,'\Cdiff --git \zs\%([abciow12]/.*\|/dev/null\)\ze \%([abciow12]/.*\|/dev/null\)')
|
|
|
|
|
let ref = matchstr(line,'\Cdiff --git \%([abciow12]/.*\|/dev/null\) \zs\%([abciow12]/.*\|/dev/null\)')
|
|
|
|
|
let dcmd = 'Gdiff!'
|
|
|
|
|
|
|
|
|
|
elseif line('$') == 1 && getline('.') =~ '^\x\{40\}$'
|
|
|
|
|
@@ -2946,18 +2968,21 @@ function! s:cfile() abort
|
|
|
|
|
let ref = ''
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if myhash ==# ''
|
|
|
|
|
let ref = s:sub(ref,'^a/','HEAD:')
|
|
|
|
|
let ref = s:sub(ref,'^b/',':0:')
|
|
|
|
|
if exists('dref')
|
|
|
|
|
let dref = s:sub(dref,'^a/','HEAD:')
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
let ref = s:sub(ref,'^a/',myhash.'^:')
|
|
|
|
|
let ref = s:sub(ref,'^b/',myhash.':')
|
|
|
|
|
if exists('dref')
|
|
|
|
|
let dref = s:sub(dref,'^a/',myhash.'^:')
|
|
|
|
|
endif
|
|
|
|
|
let prefixes = {
|
|
|
|
|
\ '1': '',
|
|
|
|
|
\ '2': '',
|
|
|
|
|
\ 'b': ':0:',
|
|
|
|
|
\ 'i': ':0:',
|
|
|
|
|
\ 'o': '',
|
|
|
|
|
\ 'w': ''}
|
|
|
|
|
|
|
|
|
|
if len(myhash)
|
|
|
|
|
let prefixes.a = myhash.'^:'
|
|
|
|
|
let prefixes.b = myhash.':'
|
|
|
|
|
endif
|
|
|
|
|
let ref = substitute(ref, '^\(\w\)/', '\=get(prefixes, submatch(1), "HEAD:")', '')
|
|
|
|
|
if exists('dref')
|
|
|
|
|
let dref = substitute(dref, '^\(\w\)/', '\=get(prefixes, submatch(1), "HEAD:")', '')
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if ref ==# '/dev/null'
|
|
|
|
|
@@ -3065,7 +3090,7 @@ function! fugitive#foldtext() abort
|
|
|
|
|
endif
|
|
|
|
|
endfor
|
|
|
|
|
if filename ==# ''
|
|
|
|
|
let filename = matchstr(getline(v:foldstart), '^diff .\{-\} a/\zs.*\ze b/')
|
|
|
|
|
let filename = matchstr(getline(v:foldstart), '^diff .\{-\} [abciow12]/\zs.*\ze [abciow12]/')
|
|
|
|
|
endif
|
|
|
|
|
if filename ==# ''
|
|
|
|
|
let filename = getline(v:foldstart)[5:-1]
|
|
|
|
|
|