Last active
March 16, 2019 08:44
-
-
Save gauteh/d2eb59fbb95bda9f3623436bd643203f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ---------------------------------------------------------------------------- | |
" DiffRev | |
" ---------------------------------------------------------------------------- | |
let s:git_status_dictionary = { | |
\ "A": "Added", | |
\ "B": "Broken", | |
\ "C": "Copied", | |
\ "D": "Deleted", | |
\ "M": "Modified", | |
\ "R": "Renamed", | |
\ "T": "Changed", | |
\ "U": "Unmerged", | |
\ "X": "Unknown" | |
\ } | |
function! s:get_diff_files(rev) | |
Gcd | |
exe 'nnoremap <leader>gr :Gdiff ' . a:rev . ':%<CR>' | |
let list = map(split(system( | |
\ 'git diff --name-status '.a:rev), '\n'), | |
\ '{"filename": matchstr(v:val, "\\S\\+$"),"text":s:git_status_dictionary[matchstr(v:val, "^\\w")]}' | |
\ ) | |
call setqflist(list) | |
copen | |
endfunction | |
command! -nargs=1 DiffRev call s:get_diff_files(<q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment