mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 12:33:46 -05:00
Support REVERT_HEAD and CHERRY_PICK_HEAD
This commit is contained in:
@@ -740,6 +740,17 @@ function! s:DirRev(url) abort
|
|||||||
return [dir, (commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')]
|
return [dir, (commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:merge_heads = ['MERGE_HEAD', 'REBASE_HEAD', 'CHERRY_PICK_HEAD', 'REVERT_HEAD']
|
||||||
|
function! s:MergeHead(...) abort
|
||||||
|
let dir = fugitive#Find('.git/', a:0 ? a:1 : s:Dir())
|
||||||
|
for head in s:merge_heads
|
||||||
|
if filereadable(dir . head)
|
||||||
|
return head
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:Owner(path, ...) abort
|
function! s:Owner(path, ...) abort
|
||||||
let dir = a:0 ? a:1 : s:Dir()
|
let dir = a:0 ? a:1 : s:Dir()
|
||||||
if empty(dir)
|
if empty(dir)
|
||||||
@@ -752,12 +763,11 @@ function! s:Owner(path, ...) abort
|
|||||||
return commit
|
return commit
|
||||||
elseif commit ==# '2'
|
elseif commit ==# '2'
|
||||||
return 'HEAD^{}'
|
return 'HEAD^{}'
|
||||||
|
elseif commit ==# '0'
|
||||||
|
return ''
|
||||||
endif
|
endif
|
||||||
if filereadable(actualdir . 'MERGE_HEAD')
|
let merge_head = s:MergeHead()
|
||||||
let merge_head = 'MERGE_HEAD'
|
if empty(merge_head)
|
||||||
elseif filereadable(actualdir . 'REBASE_HEAD')
|
|
||||||
let merge_head = 'REBASE_HEAD'
|
|
||||||
else
|
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
if commit ==# '3'
|
if commit ==# '3'
|
||||||
@@ -1464,6 +1474,12 @@ function! fugitive#PathComplete(...) abort
|
|||||||
return call('fugitive#CompletePath', a:000)
|
return call('fugitive#CompletePath', a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:CompleteHeads(dir) abort
|
||||||
|
let dir = fugitive#Find('.git/', a:dir)
|
||||||
|
return sort(filter(['HEAD', 'FETCH_HEAD', 'ORIG_HEAD'] + s:merge_heads, 'filereadable(dir . v:val)')) +
|
||||||
|
\ sort(s:LinesError('rev-parse', '--symbolic', '--branches', '--tags', '--remotes')[0])
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! fugitive#CompleteObject(base, ...) abort
|
function! fugitive#CompleteObject(base, ...) abort
|
||||||
let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir()
|
let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir()
|
||||||
let cwd = getcwd()
|
let cwd = getcwd()
|
||||||
@@ -1478,8 +1494,7 @@ function! fugitive#CompleteObject(base, ...) abort
|
|||||||
if a:base =~# '^refs/'
|
if a:base =~# '^refs/'
|
||||||
let results += map(s:GlobComplete(fugitive#CommonDir(dir) . '/', a:base . '*'), 's:Slash(v:val)')
|
let results += map(s:GlobComplete(fugitive#CommonDir(dir) . '/', a:base . '*'), 's:Slash(v:val)')
|
||||||
elseif a:base !~# '^\.\=/\|^:('
|
elseif a:base !~# '^\.\=/\|^:('
|
||||||
let heads = ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'refs/']
|
let heads = s:CompleteHeads(dir)
|
||||||
let heads += sort(s:LinesError(["rev-parse","--symbolic","--branches","--tags","--remotes"], dir)[0])
|
|
||||||
if filereadable(fugitive#Find('.git/refs/stash', dir))
|
if filereadable(fugitive#Find('.git/refs/stash', dir))
|
||||||
let heads += ["stash"]
|
let heads += ["stash"]
|
||||||
let heads += sort(s:LinesError(["stash","list","--pretty=format:%gd"], dir)[0])
|
let heads += sort(s:LinesError(["stash","list","--pretty=format:%gd"], dir)[0])
|
||||||
@@ -1529,9 +1544,8 @@ function! s:CompleteSub(subcommand, A, L, P, ...) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompleteRevision(A, L, P) abort
|
function! s:CompleteRevision(A, L, P, ...) abort
|
||||||
return s:FilterEscape(['HEAD', 'FETCH_HEAD', 'MERGE_HEAD', 'ORIG_HEAD'] +
|
return s:FilterEscape(s:CompleteHeads(s:Dir()), a:A)
|
||||||
\ s:LinesError('rev-parse', '--symbolic', '--branches', '--tags', '--remotes')[0], a:A)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompleteRemote(A, L, P) abort
|
function! s:CompleteRemote(A, L, P) abort
|
||||||
|
|||||||
Reference in New Issue
Block a user