Press dh in :Gstatus to do a horizontal diff

This commit is contained in:
Tim Pope 2010-07-25 22:38:10 -04:00
parent 562ab96b2f
commit 2b9faa8c7f
2 changed files with 11 additions and 8 deletions

View File

@ -52,9 +52,10 @@ that are part of Git repositories).
*fugitive-:Gstatus* *fugitive-:Gstatus*
:Gstatus Bring up the output of git-status in the preview :Gstatus Bring up the output of git-status in the preview
window. Press D to |:Gdiff| the file on the cursor window. Press D to |:Gdiff| the file on the cursor
line. Press - to stage or unstage the file on the line, or dh to |:Gdiff!|. Press - to stage or unstage
cursor line. Press p to do so on a per hunk basis the file on the cursor line. Press p to do so on a
(--patch). Press C to invoke |:Gcommit|. per hunk basis (--patch). Press C to invoke
|:Gcommit|.
*fugitive-:Gcommit* *fugitive-:Gcommit*
:Gcommit [args] A wrapper around git-commit. If there is nothing :Gcommit [args] A wrapper around git-commit. If there is nothing

View File

@ -538,7 +538,7 @@ function! fugitive#reload_status() abort
endfor endfor
endfunction endfunction
function! s:StageDiff() abort function! s:StageDiff(bang) abort
let section = getline(search('^# .*:$','bnW')) let section = getline(search('^# .*:$','bnW'))
let line = getline('.') let line = getline('.')
let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*') let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
@ -549,13 +549,13 @@ function! s:StageDiff() abort
elseif line =~# '^#\trenamed:' && filename =~ ' -> ' elseif line =~# '^#\trenamed:' && filename =~ ' -> '
let [old, new] = split(filename,' -> ') let [old, new] = split(filename,' -> ')
execute 'Gedit '.s:fnameescape(':0:'.new) execute 'Gedit '.s:fnameescape(':0:'.new)
return 'Gdiff HEAD:'.s:fnameescape(old) return 'Gdiff'.a:bang.' HEAD:'.s:fnameescape(old)
elseif section == '# Changes to be committed:' elseif section == '# Changes to be committed:'
execute 'Gedit '.s:fnameescape(':0:'.filename) execute 'Gedit '.s:fnameescape(':0:'.filename)
return 'Gdiff -' return 'Gdiff'.a:bang.' -'
else else
execute 'Gedit '.s:fnameescape('/'.filename) execute 'Gedit '.s:fnameescape('/'.filename)
return 'Gdiff' return 'Gdiff'.a:bang
endif endif
endfunction endfunction
@ -1377,7 +1377,9 @@ function! s:BufReadIndex()
setlocal ro noma nomod nomodeline bufhidden=delete setlocal ro noma nomod nomodeline bufhidden=delete
nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe <SID>BufReadIndex()<CR> nnoremap <buffer> <silent> a :<C-U>let b:fugitive_display_format += 1<Bar>exe <SID>BufReadIndex()<CR>
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe <SID>BufReadIndex()<CR> nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= 1<Bar>exe <SID>BufReadIndex()<CR>
nnoremap <buffer> <silent> D :<C-U>execute <SID>StageDiff()<CR> nnoremap <buffer> <silent> D :<C-U>execute <SID>StageDiff('')<CR>
nnoremap <buffer> <silent> dd :<C-U>execute <SID>StageDiff('')<CR>
nnoremap <buffer> <silent> dh :<C-U>execute <SID>StageDiff('!')<CR>
nnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line('.'),line('.')+v:count1-1)<CR> nnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line('.'),line('.')+v:count1-1)<CR>
xnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line("'<"),line("'>"))<CR> xnoremap <buffer> <silent> - :<C-U>execute <SID>StageToggle(line("'<"),line("'>"))<CR>
nnoremap <buffer> <silent> p :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR> nnoremap <buffer> <silent> p :<C-U>execute <SID>StagePatch(line('.'),line('.')+v:count1-1)<CR>