:Gdiff does a three-way during a conflict
This commit is contained in:
parent
04b845a4e9
commit
b65030cd3b
@ -92,9 +92,12 @@ that are part of Git repositories).
|
||||
the index.
|
||||
|
||||
*fugitive-:Gdiff*
|
||||
:Gdiff [revision] Perform a |vimdiff| the current file against the index
|
||||
or the given revision. Use |do| and |dp| and write to
|
||||
the index file to simulate git add -p.
|
||||
:Gdiff [revision] Perform a |vimdiff| against the current file in the
|
||||
given revision. With no argument, the version in the
|
||||
index is used (which means a three-way diff during a
|
||||
merge conflict, making it a git mergetool
|
||||
alternative). Use |do| and |dp| and write to the
|
||||
index file to simulate git add -p.
|
||||
|
||||
*fugitive-:Gmove*
|
||||
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
||||
|
@ -649,29 +649,43 @@ endfunction
|
||||
|
||||
call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gdiff :execute s:Diff(<f-args>)")
|
||||
|
||||
augroup fugitive_diff
|
||||
autocmd BufWinLeave * if winnr('$') == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff! | endif
|
||||
autocmd BufWinEnter * if winnr('$') == 1 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff | endif
|
||||
augroup END
|
||||
|
||||
function! s:Diff(...) abort
|
||||
if exists(':DiffGitCached')
|
||||
return 'DiffGitCached'
|
||||
elseif (!a:0 || a:1 == ':') && s:buffer().commit() =~# '^[0-1]\=$' && s:repo().git_chomp_in_tree('ls-files', '--unmerged', '--', s:buffer().path()) !=# ''
|
||||
leftabove vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':2'))`
|
||||
diffthis
|
||||
wincmd p
|
||||
rightbelow vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':3'))`
|
||||
diffthis
|
||||
wincmd p
|
||||
diffthis
|
||||
return ''
|
||||
elseif a:0
|
||||
if a:1 ==# ''
|
||||
return ''
|
||||
elseif a:1 == ':' || a:1 == '/'
|
||||
let file = s:buffer().path(a:1)
|
||||
elseif a:1 ==# '/'
|
||||
let file = s:buffer().path('/')
|
||||
elseif a:1 ==# ':'
|
||||
let file = s:buffer().path(':0:')
|
||||
else
|
||||
let file = s:buffer().expand(a:1)
|
||||
endif
|
||||
if file !~ ':' && file !~ '^/'
|
||||
let file = file.s:buffer().path(':')
|
||||
let file = file.s:buffer().path(':0:')
|
||||
endif
|
||||
else
|
||||
let file = s:buffer().path(s:buffer().commit() == '' ? ':' : '/')
|
||||
let file = s:buffer().path(s:buffer().commit() == '' ? ':0:' : '/')
|
||||
endif
|
||||
try
|
||||
vsplit `=fugitive#buffer().repo().translate(file)`
|
||||
let b:fugitive_restore = 'diffoff!'
|
||||
diffthis
|
||||
wincmd p
|
||||
let b:fugitive_restore = 'diffoff!'
|
||||
diffthis
|
||||
return ''
|
||||
catch /^fugitive:/
|
||||
|
Loading…
x
Reference in New Issue
Block a user