From 795389215c6c9bb4e3958afcd8b29ad5e8839f01 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Tue, 14 Nov 2023 16:08:16 +0530 Subject: [PATCH] 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/ --- nvim/.config/nvim/after/ftplugin/git.vim | 2 +- nvim/.config/nvim/autoload/git.vim | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/git.vim b/nvim/.config/nvim/after/ftplugin/git.vim index 08b38fe..0e5233f 100644 --- a/nvim/.config/nvim/after/ftplugin/git.vim +++ b/nvim/.config/nvim/after/ftplugin/git.vim @@ -10,11 +10,11 @@ nnoremap gf :call git#git_format_patch() xnoremap gf :call git#git_format_patch_range() nnoremap gl :call git#git_branch_log() nnoremap gL :call git#git_branch_log_pretty() -nnoremap gr :call git#git_rebase_branch() nnoremap gR :call git#git_reflog_restore() nnoremap gn git#git_branch_rename() nnoremap gp git#git_push_commit() +nnoremap gr git#git_rebase_branch() " Jump to sections of diff nnoremap [c ?^@@ diff --git a/nvim/.config/nvim/autoload/git.vim b/nvim/.config/nvim/autoload/git.vim index 65f5e81..8f03ec3 100644 --- a/nvim/.config/nvim/autoload/git.vim +++ b/nvim/.config/nvim/autoload/git.vim @@ -237,14 +237,13 @@ function! git#git_rebase_branch() abort let branch = split(line, "/") if len(branch) == 1 " Handles the case for local branch - execute "keepalt Git rebase " . branch[0] + return ":Git rebase HEAD~" . " --onto " . branch[0] else " Handles the case for remote remotes/remote_name/branch_name let remote = branch[1] let branch = branch[2] - execute "keepalt Git rebase " . remote . "/" . branch + return ":Git rebase HEAD~" . " --onto " . remote . "/" . branch endif - silent execute "keepalt bw" endfunction " Git reflog should be run first before invoking this