From b7d99f98980bcb948dfdc542eeef95647f9dda59 Mon Sep 17 00:00:00 2001 From: rbong Date: Wed, 26 Dec 2018 08:39:34 -0500 Subject: [PATCH 1/2] Call Gcommit on Grebase --continue On a rebase instruction that should result in an immediate commit, the quickfix list will be closed and Gcommit will be called. --- autoload/fugitive.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d121db431a..8fea11e1ca 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2308,6 +2308,13 @@ function! s:RemoteComplete(A, L, P) abort return join(matches, "\n") endfunction +function! s:HasRebaseCommitCmd() abort + if !filereadable(b:git_dir . '/rebase-merge/amend') || !filereadable(b:git_dir . '/rebase-merge/done') + return 0 + endif + return get(readfile(b:git_dir . '/rebase-merge/done'), -1, '') =~# '^[^e]' +endfunction + function! fugitive#Cwindow() abort if &buftype == 'quickfix' cwindow @@ -2345,6 +2352,7 @@ function! s:Merge(cmd, bang, mods, args) abort \ . '%+ECannot %.%#: Your index contains uncommitted changes.,' \ . '%+EThere is no tracking information for the current branch.,' \ . '%+EYou are not currently on a branch. Please specify which,' + \ . '%+I%.%#git rebase --continue,' \ . 'CONFLICT (%m): %f deleted in %.%#,' \ . 'CONFLICT (%m): Merge conflict in %f,' \ . 'CONFLICT (%m): Rename \"%f\"->%.%#,' @@ -2383,10 +2391,13 @@ function! s:Merge(cmd, bang, mods, args) abort execute cdback endtry call fugitive#ReloadStatus() - if empty(filter(getqflist(),'v:val.valid')) + if empty(filter(getqflist(),'v:val.valid && v:val.type !=# "I"')) if !had_merge_msg && filereadable(b:git_dir . '/MERGE_MSG') cclose return mods . 'Gcommit --no-status -n -t '.s:shellesc(b:git_dir . '/MERGE_MSG') + elseif a:cmd =~# '^rebase' && ' '.a:args =~# ' --continue' && s:HasRebaseCommitCmd() + cclose + return mods . 'Gcommit --amend' endif endif let qflist = getqflist() From 7343f0eb40705dc3c7e6c3de13729aafed733c1d Mon Sep 17 00:00:00 2001 From: rbong Date: Wed, 26 Dec 2018 10:06:46 -0500 Subject: [PATCH 2/2] Open todo file on Grebase --edit-todo --- autoload/fugitive.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 8fea11e1ca..0a0cdeac78 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2336,7 +2336,7 @@ let s:common_efm = '' function! s:Merge(cmd, bang, mods, args) abort let mods = substitute(a:mods, '\C', '', '') . ' ' - if a:cmd =~# '^rebase' && ' '.a:args =~# ' -i\| --interactive\| --edit-todo' + if a:cmd =~# '^rebase' && ' '.a:args =~# ' -i\| --interactive' return 'echoerr "git rebase --interactive not supported"' endif let [mp, efm] = [&l:mp, &l:efm] @@ -2398,6 +2398,8 @@ function! s:Merge(cmd, bang, mods, args) abort elseif a:cmd =~# '^rebase' && ' '.a:args =~# ' --continue' && s:HasRebaseCommitCmd() cclose return mods . 'Gcommit --amend' + elseif a:cmd =~# '^rebase' && ' '.a:args =~# ' --edit-todo' + return mods . 'Gsplit ' . s:fnameescape(b:git_dir . '/rebase-merge/git-rebase-todo') . ' | setlocal bufhidden=wipe nobuflisted' endif endif let qflist = getqflist()