Make GitCompare the one ring to compare them all

This commit is contained in:
Talia 2018-04-12 09:41:11 +02:00
parent 6d8b1a41d2
commit 9108000b77

43
vimrc
View file

@ -366,16 +366,16 @@ endfun
function! s:git_prev() function! s:git_prev()
if !exists("b:git_revision_hash") || !exists("b:git_original_file") if !exists("b:git_revision_hash") || !exists("b:git_original_file")
echo "Error 01: Not a file@revision buffer!" let l:new_revision = s:git_history()[0]
return else
let l:history = s:git_history()
let l:idx = index(l:history, b:git_revision_hash)
if l:idx == -1
echo "Error 03: cannot find revision ".b:git_revision_hash
return
end
let l:new_revision = get(l:history, l:idx+1, "FIRST")
end end
let l:history = s:git_history()
let l:idx = index(l:history, b:git_revision_hash)
if l:idx == -1
echo "Error 02"
return
end
let l:new_revision = get(l:history, l:idx+1, "FIRST")
if l:new_revision=="FIRST" if l:new_revision=="FIRST"
echo "Already at earliest revision! ".l:new_revision echo "Already at earliest revision! ".l:new_revision
return return
@ -412,12 +412,20 @@ function! s:file_at_revision(rev)
call s:git_info() call s:git_info()
endfun endfun
function! s:git_diff(revision) function! s:git_diff(...)
diffthis if a:0
split diffthis
call s:file_at_revision(a:revision) split
au BufUnload <buffer> diffoff! call s:file_at_revision(a:1)
diffthis au BufUnload <buffer> diffoff!
diffthis
else
if exists("b:git_revision_hash")
call s:git_diff(get(s:git_history(), index(s:git_history(), b:git_revision_hash)+1, "NIL"))
else
call s:git_diff("HEAD")
end
end
endfun endfun
command! GitNext call <sid>git_next() command! GitNext call <sid>git_next()
@ -426,10 +434,7 @@ command! GitFirst call <sid>git_first()
command! GitLast call <sid>git_last() command! GitLast call <sid>git_last()
command! GitInfo call <sid>git_info() command! GitInfo call <sid>git_info()
command! -nargs=1 GitCheckout call <sid>file_at_revision(<f-args>) command! -nargs=1 GitCheckout call <sid>file_at_revision(<f-args>)
command! -nargs=1 GitCompare call <sid>uncommitted(<f-args>) command! -nargs=? GitCompare call <sid>git_diff(<f-args>)
command! Uncommitted call <sid>git_diff("HEAD")
" command! -nargs=1 GitAt call <sid>s:file_at_revision(<f-args>)
" Doesn't work for talos knows what reason
" === FILE STUFF === " === FILE STUFF ===