nvim: autoload/ftplugin: git: Update git rebase branch implementation

See this for reference.
https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs/
This commit is contained in:
Sanchayan Maity 2023-11-14 16:08:16 +05:30
parent 1bcb0b2ba5
commit 795389215c
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3
2 changed files with 3 additions and 4 deletions

View file

@ -10,11 +10,11 @@ nnoremap <buffer> <Leader>gf :call git#git_format_patch()<CR>
xnoremap <buffer> <Leader>gf :call git#git_format_patch_range()<CR> xnoremap <buffer> <Leader>gf :call git#git_format_patch_range()<CR>
nnoremap <buffer> <Leader>gl :call git#git_branch_log()<CR> nnoremap <buffer> <Leader>gl :call git#git_branch_log()<CR>
nnoremap <buffer> <Leader>gL :call git#git_branch_log_pretty()<CR> nnoremap <buffer> <Leader>gL :call git#git_branch_log_pretty()<CR>
nnoremap <buffer> <Leader>gr :call git#git_rebase_branch()<CR>
nnoremap <buffer> <Leader>gR :call git#git_reflog_restore()<CR> nnoremap <buffer> <Leader>gR :call git#git_reflog_restore()<CR>
nnoremap <buffer> <expr> <Leader>gn git#git_branch_rename() nnoremap <buffer> <expr> <Leader>gn git#git_branch_rename()
nnoremap <buffer> <expr> <Leader>gp git#git_push_commit() nnoremap <buffer> <expr> <Leader>gp git#git_push_commit()
nnoremap <buffer> <expr> <Leader>gr git#git_rebase_branch()
" Jump to sections of diff " Jump to sections of diff
nnoremap <buffer> [c ?^@@<CR> nnoremap <buffer> [c ?^@@<CR>

View file

@ -237,14 +237,13 @@ function! git#git_rebase_branch() abort
let branch = split(line, "/") let branch = split(line, "/")
if len(branch) == 1 if len(branch) == 1
" Handles the case for local branch " Handles the case for local branch
execute "keepalt Git rebase " . branch[0] return ":Git rebase HEAD~" . " --onto " . branch[0]
else else
" Handles the case for remote remotes/remote_name/branch_name " Handles the case for remote remotes/remote_name/branch_name
let remote = branch[1] let remote = branch[1]
let branch = branch[2] let branch = branch[2]
execute "keepalt Git rebase " . remote . "/" . branch return ":Git rebase HEAD~" . " --onto " . remote . "/" . branch
endif endif
silent execute "keepalt bw"
endfunction endfunction
" Git reflog should be run first before invoking this " Git reflog should be run first before invoking this