mirror of
https://github.com/tpope/vim-fugitive.git
synced 2026-03-08 07:56:52 +08:00
Compare commits
2 Commits
master
...
0396246be2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0396246be2 | ||
|
|
f2546146c4 |
@@ -4,6 +4,11 @@
|
||||
" The functions contained within this file are for internal use only. For the
|
||||
" official API, see the commented functions in plugin/fugitive.vim.
|
||||
|
||||
if exists('g:autoloaded_fugitive')
|
||||
finish
|
||||
endif
|
||||
let g:autoloaded_fugitive = 1
|
||||
|
||||
" Section: Utility
|
||||
|
||||
function! s:function(name) abort
|
||||
@@ -2066,8 +2071,6 @@ function! s:Expand(rev, ...) abort
|
||||
endif
|
||||
elseif s:Slash(a:rev) =~# '^\a\a\+://'
|
||||
let file = substitute(a:rev, '\\\@<!\%(#\a\|%\x\x\)', '\\&', 'g')
|
||||
elseif a:rev =~# '^:[!#%$]'
|
||||
let file = ':0' . a:rev
|
||||
else
|
||||
let file = a:rev
|
||||
endif
|
||||
@@ -2694,7 +2697,7 @@ function! s:MapStatus() abort
|
||||
call s:MapMotion('gP', "exe <SID>StageJump(v:count, 'Unpulled')")
|
||||
call s:MapMotion('gr', "exe <SID>StageJump(v:count, 'Rebasing')")
|
||||
call s:Map('n', 'C', ":echoerr 'fugitive: C has been removed in favor of cc'<CR>", '<silent><unique>')
|
||||
call s:Map('n', 'a', ":echoerr 'fugitive: a has been removed in favor of s'<CR>", '<silent><unique>')
|
||||
call s:Map('n', 'a', ":<C-U>execute <SID>Do('Toggle',0)<CR>", '<silent>')
|
||||
call s:Map('n', 'i', ":<C-U>execute <SID>NextExpandedHunk(v:count1)<CR>", '<silent>')
|
||||
call s:Map('n', "=", ":<C-U>execute <SID>StageInline('toggle',line('.'),v:count)<CR>", '<silent>')
|
||||
call s:Map('n', "<", ":<C-U>execute <SID>StageInline('hide', line('.'),v:count)<CR>", '<silent>')
|
||||
@@ -2937,34 +2940,20 @@ function! s:StatusRender(stat) abort
|
||||
endif
|
||||
|
||||
let sequencing = []
|
||||
try
|
||||
let sequencer_todo = reverse(readfile(fugitive#Find('.git/sequencer/todo', dir)))
|
||||
catch
|
||||
endtry
|
||||
if exists('sequencer_todo')
|
||||
for line in sequencer_todo
|
||||
if filereadable(fugitive#Find('.git/sequencer/todo', dir))
|
||||
for line in reverse(readfile(fugitive#Find('.git/sequencer/todo', dir)))
|
||||
let match = matchlist(line, '^\(\l\+\)\s\+\(\x\{4,\}\)\s\+\(.*\)')
|
||||
if len(match) && match[1] !~# 'exec\|merge\|label'
|
||||
call add(sequencing, {'type': 'Rebase', 'status': get(s:rebase_abbrevs, match[1], match[1]), 'commit': match[2], 'subject': match[3]})
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
try
|
||||
let merge_msg = get(readfile(fugitive#Find('.git/MERGE_MSG', dir), '', 1), 0, '')
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
if exists('merge_msg')
|
||||
elseif filereadable(fugitive#Find('.git/MERGE_MSG', dir))
|
||||
if filereadable(fugitive#Find('.git/CHERRY_PICK_HEAD', dir))
|
||||
let pick_head = fugitive#Execute(['rev-parse', '--short', 'CHERRY_PICK_HEAD', '--'], dir).stdout[0]
|
||||
if !empty(pick_head)
|
||||
call add(sequencing, {'type': 'Rebase', 'status': 'pick', 'commit': pick_head, 'subject': merge_msg})
|
||||
endif
|
||||
call add(sequencing, {'type': 'Rebase', 'status': 'pick', 'commit': pick_head, 'subject': get(readfile(fugitive#Find('.git/MERGE_MSG', dir)), 0, '')})
|
||||
elseif filereadable(fugitive#Find('.git/REVERT_HEAD', dir))
|
||||
let pick_head = fugitive#Execute(['rev-parse', '--short', 'REVERT_HEAD', '--'], dir).stdout[0]
|
||||
if !empty(pick_head)
|
||||
call add(sequencing, {'type': 'Rebase', 'status': 'revert', 'commit': pick_head, 'subject': merge_msg})
|
||||
endif
|
||||
call add(sequencing, {'type': 'Rebase', 'status': 'revert', 'commit': pick_head, 'subject': get(readfile(fugitive#Find('.git/MERGE_MSG', dir)), 0, '')})
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -2987,7 +2976,7 @@ function! s:StatusRender(stat) abort
|
||||
endif
|
||||
|
||||
call s:AddSection(to, 'Rebasing ' . rebasing_head, rebasing)
|
||||
call s:AddSection(to, get(get(sequencing, 0, {}), 'status', '') ==# 'revert' ? 'Reverting' : 'Cherry Picking', sequencing)
|
||||
call s:AddSection(to, get(get(sequencing, 0, {}), 'tous', '') ==# 'revert' ? 'Reverting' : 'Cherry Picking', sequencing)
|
||||
call s:AddSection(to, 'Untracked', untracked)
|
||||
call s:AddDiffSection(to, stat, 'Unstaged', unstaged)
|
||||
call s:AddDiffSection(to, stat, 'Staged', staged)
|
||||
@@ -4106,7 +4095,7 @@ function! s:CompletableSubcommands(dir) abort
|
||||
let c_exec_path = s:cpath(s:VimExecPath())
|
||||
if !has_key(s:path_subcommands, c_exec_path)
|
||||
if fugitive#GitVersion(2, 18)
|
||||
let [lines, exec_error] = s:LinesError([a:dir, '--list-cmds=list-mainporcelain,nohelpers,list-complete,others'])
|
||||
let [lines, exec_error] = s:LinesError([a:dir, '--list-cmds=list-mainporcelain,nohelpers,list-complete'])
|
||||
call filter(lines, 'v:val =~# "^\\S\\+$"')
|
||||
if !exec_error && len(lines)
|
||||
let s:path_subcommands[c_exec_path] = lines
|
||||
@@ -4120,6 +4109,16 @@ function! s:CompletableSubcommands(dir) abort
|
||||
endif
|
||||
endif
|
||||
let commands = copy(s:path_subcommands[c_exec_path])
|
||||
for path in split($PATH, has('win32') ? ';' : ':')
|
||||
if path !~# '^/\|^\a:[\\/]'
|
||||
continue
|
||||
endif
|
||||
let cpath = s:cpath(path)
|
||||
if !has_key(s:path_subcommands, cpath)
|
||||
let s:path_subcommands[cpath] = filter(map(s:GlobComplete(path.'/git-', '*', 1),'substitute(v:val,"\\.exe$","","")'), 'v:val !~# "--\\|/"')
|
||||
endif
|
||||
call extend(commands, s:path_subcommands[cpath])
|
||||
endfor
|
||||
call extend(commands, keys(fugitive#ConfigGetRegexp('^alias\.\zs[^.]\+$', a:dir)))
|
||||
let configured = split(FugitiveConfigGet('completion.commands', a:dir), '\s\+')
|
||||
let rejected = {}
|
||||
@@ -7367,6 +7366,7 @@ function! s:BlameMaps(is_ftplugin) abort
|
||||
call s:Map('n', '~', ':<C-U>exe <SID>BlameJump("~".v:count1)<CR>', '<silent>', ft)
|
||||
call s:Map('n', 'i', ':<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>', '<silent>', ft)
|
||||
call s:Map('n', 'o', ':<C-U>exe <SID>BlameCommit("split")<CR>', '<silent>', ft)
|
||||
call s:Map('n', 'gO', ':<C-U>exe <SID>BlameCommit("vsplit")<CR>', '<silent>', ft)
|
||||
call s:Map('n', 'O', ':<C-U>exe <SID>BlameCommit("tabedit")<CR>', '<silent>', ft)
|
||||
call s:Map('n', 'p', ':<C-U>exe <SID>BlameCommit("pedit")<CR>', '<silent>', ft)
|
||||
exe s:Map('n', '.', ":<C-U> <C-R>=substitute(<SID>BlameCommitFileLnum()[0],'^$','@','')<CR><Home>", '', ft)
|
||||
@@ -7436,12 +7436,9 @@ function! s:BrowserOpen(url, mods, echo_copy) abort
|
||||
else
|
||||
if !exists('g:loaded_netrw')
|
||||
runtime! autoload/netrw.vim
|
||||
runtime! autoload/netrw/os.vim
|
||||
endif
|
||||
if exists('*netrw#Open')
|
||||
return 'echo '.string(url).'|' . mods . 'call netrw#Open('.string(url).')'
|
||||
elseif exists('*netrw#os#Open')
|
||||
return 'echo '.string(url).'|' . mods . 'call netrw#os#Open('.string(url).')'
|
||||
elseif exists('*netrw#BrowseX')
|
||||
return 'echo '.string(url).'|' . mods . 'call netrw#BrowseX('.string(url).', 0)'
|
||||
elseif exists('*netrw#NetrwBrowseX')
|
||||
@@ -8034,8 +8031,8 @@ function! fugitive#MapJumps(...) abort
|
||||
call s:MapMotion(']]', 'exe <SID>NextSection(v:count1)')
|
||||
call s:MapMotion('[]', 'exe <SID>PreviousSectionEnd(v:count1)')
|
||||
call s:MapMotion('][', 'exe <SID>NextSectionEnd(v:count1)')
|
||||
call s:Map('no', '*', '<SID>PatchSearchExpr(0)', '<expr>')
|
||||
call s:Map('no', '#', '<SID>PatchSearchExpr(1)', '<expr>')
|
||||
call s:Map('nxo', '*', '<SID>PatchSearchExpr(0)', '<expr>')
|
||||
call s:Map('nxo', '#', '<SID>PatchSearchExpr(1)', '<expr>')
|
||||
endif
|
||||
call s:Map('n', 'S', ':<C-U>echoerr "Use gO"<CR>', '<silent><unique>')
|
||||
call s:Map('n', 'dq', ":<C-U>call fugitive#DiffClose()<CR>", '<silent>')
|
||||
|
||||
@@ -68,6 +68,7 @@ that are part of Git repositories).
|
||||
<CR> close blame, and jump to patch that added line
|
||||
(or directly to blob for boundary commit)
|
||||
o jump to patch or blob in horizontal split
|
||||
gO jump to patch or blob in vertical split
|
||||
O jump to patch or blob in new tab
|
||||
p jump to patch or blob in preview window
|
||||
- reblame at commit
|
||||
|
||||
Reference in New Issue
Block a user