commit a21ca7e86e0daf8246db791c0084086b87cdc586 (tree)
parent f779b90fbd65c2a656b77d23d369d15dffbf2b92
Author: Maksim Odnoletkov <odnoletkov@mail.ru>
Date: Tue, 17 Sep 2019 23:17:27 +0100
Support X for submodules
Staged/[MD]:
Unstage and checkout superproject recorded version
Staged/A:
Noop. 'git rm -f' would be appropriate but it is destructive for
non-staged changes and hard to undo
Unstaged/A:
Noop. Hard to reproduce in practice, 'git status' doesn't handle it well
and hard to undo
Unstaged/[MD]:
Checkout superproject recorded version
Unstaged/[m?]:
Noop. Discarding submodules content changes is too complicated.
Workaround is to <CR> to submodule and discard from it's :Gstatus.
Diffstat:
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -1654,12 +1654,12 @@ function! fugitive#BufReadStatus() abort
let i += 1
let file = output[i] . ' -> ' . matchstr(file, ' \zs.*')
endif
+ let sub = matchstr(line, '^[12u] .. \zs....')
if line[2] !=# '.'
- call add(staged, {'type': 'File', 'status': line[2], 'filename': file})
+ call add(staged, {'type': 'File', 'status': line[2], 'filename': file, 'sub': sub})
endif
if line[3] !=# '.'
- let sub = matchstr(line, '^[12u] .. \zs....')
- call add(unstaged, {'type': 'File', 'status': get({'C':'M','M':'?','U':'?'}, matchstr(sub, 'S\.*\zs[CMU]'), line[3]), 'filename': file})
+ call add(unstaged, {'type': 'File', 'status': get({'C':'M','M':'?','U':'?'}, matchstr(sub, 'S\.*\zs[CMU]'), line[3]), 'filename': file, 'sub': sub})
endif
endif
let i += 1
@@ -1697,12 +1697,12 @@ function! fugitive#BufReadStatus() abort
let i += 1
endif
if line[0] !~# '[ ?!#]'
- call add(staged, {'type': 'File', 'status': line[0], 'filename': files})
+ call add(staged, {'type': 'File', 'status': line[0], 'filename': files, 'sub': ''})
endif
if line[0:1] ==# '??'
call add(untracked, {'type': 'File', 'status': line[1], 'filename': files})
elseif line[1] !~# '[ !#]'
- call add(unstaged, {'type': 'File', 'status': line[1], 'filename': files})
+ call add(unstaged, {'type': 'File', 'status': line[1], 'filename': files, 'sub': ''})
endif
endwhile
endif
@@ -3074,6 +3074,20 @@ 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, {}), 'sub')
+ if sub =~# '^S'
+ if info.status ==# 'A'
+ continue
+ endif
+ if info.section ==# 'Staged'
+ call s:TreeChomp('reset', '--', info.paths[0])
+ endif
+ if info.status =~# '[MD]'
+ call s:TreeChomp('submodule', 'update', '--', info.paths[0])
+ call add(restore, ':Git -C ' . info.relative[0] . ' checkout -')
+ endif
+ continue
+ endif
if info.status ==# 'D'
let undo = 'Gremove'
elseif info.paths[0] =~# '/$'