nvim: autoload/git: Use difftool for review

The difftool version is actually useful since it populates the quickfix
list when the -y argument is not used. This gives rise to a possibility
where the quickfix list can be filtered to ignore or look only at files
we want.

While at it also add the version which opens each changed file in a tab
and gives a diffsplit view.
This commit is contained in:
Sanchayan Maity 2022-04-02 17:34:13 +05:30
parent 6ae7da9eca
commit 2d17fe00ab
2 changed files with 13 additions and 3 deletions

View file

@ -14,6 +14,8 @@ nnoremap <Leader>gF :call git#git_fetch_origin_merge()<CR>
nnoremap <Leader>gg :Git<CR>
nnoremap <Leader>gh :Git log --grep=
nnoremap <Leader>gH :<C-U>Git log -G<C-r><C-w>
nnoremap <Leader>gk :call git#git_review()<CR>
nnoremap <Leader>gK :call git#git_review_fileview()<CR>
nnoremap <Leader>gl :Git log --stat %<CR>
nnoremap <Leader>gL :Git log --stat -n 100<CR>
xnoremap <Leader>gl :<C-U>call git#git_log_range()<CR>
@ -23,7 +25,7 @@ nnoremap <Leader>gM :call git#git_merge_origin()<CR>
nnoremap <Leader>gn :Git branch -m<SPACE>
nnoremap <Leader>go :call git#git_log_compare()<CR>
nnoremap <Leader>gr :call git#git_rebase_origin()<CR>
nnoremap <Leader>gR :call git#git_review()<CR>
nnoremap <Leader>gR :Git rebase --abort<CR>
nnoremap <Leader>g- :call git#git_stash()<CR>:e<CR>
nnoremap <Leader>g+ :Git stash pop stash@
nnoremap <Leader>gs :Git stash list<CR>

View file

@ -274,11 +274,19 @@ function! git#git_rebase_origin() abort
execute "Git rebase origin/" . default[3]
endfunction
" Opens the output of Git diff main...<current_branch> in a tab for review
" Opens the output of Git difftool main...<current_branch> for review
function! git#git_review() abort
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
let current = trim(system("git branch --show-current"))
execute "Gtabedit | Git diff " . default[3] . "..." . current . "| only"
execute "Gtabedit | Git difftool " . default[3] . "..." . current
endfunction
" Opens the output of Git difftool main...<current_branch> for review. Each
" file is opened in a tab.
function! git#git_review_fileview() abort
let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/')
let current = trim(system("git branch --show-current"))
execute "Git difftool -y " . default[3] . "..." . current
endfunction
" Generate a helpful name when using Git stash