From 6b39f6c64163d66f7e5321f2ff10440f512f41d6 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 29 Mar 2021 20:31:50 -0400 Subject: [PATCH] Restore X on submodules References https://github.com/tpope/vim-fugitive/issues/1705 --- autoload/fugitive.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index a2a6f1e..0142115 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -3813,8 +3813,14 @@ function! s:StageDelete(lnum1, lnum2, count) abort if empty(info.paths) continue endif + let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'submodule') if info.status ==# 'D' let undo = 'GRemove' + elseif sub =~# '^S' && info.status !~# '[MD]' + let err .= '|echoerr ' . string('fugitive: will not delete submodule ' . string(info.relative[0])) + break + elseif sub =~# '^S' + let undo = 'Git checkout ' . fugitive#RevParse('HEAD', FugitiveExtractGitDir(info.paths[0]))[0:10] . ' --' elseif info.paths[0] =~# '/$' let err .= '|echoerr ' . string('fugitive: will not delete directory ' . string(info.relative[0])) break @@ -3823,6 +3829,11 @@ function! s:StageDelete(lnum1, lnum2, count) abort endif if info.patch call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : []) + elseif sub =~# '^S' + if info.section ==# 'Staged' + call s:TreeChomp('reset', '--', info.paths[0]) + endif + call s:TreeChomp('submodule', 'update', '--', info.paths[0]) elseif info.status ==# '?' call s:TreeChomp('clean', '-f', '--', info.paths[0]) elseif a:count == 2