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.
This commit is contained in:
Maksim Odnoletkov
2019-09-17 23:17:27 +01:00
committed by Tim Pope
parent f779b90fbd
commit a21ca7e86e

View File

@@ -1654,12 +1654,12 @@ function! fugitive#BufReadStatus() abort
let i += 1 let i += 1
let file = output[i] . ' -> ' . matchstr(file, ' \zs.*') let file = output[i] . ' -> ' . matchstr(file, ' \zs.*')
endif endif
let sub = matchstr(line, '^[12u] .. \zs....')
if line[2] !=# '.' 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 endif
if line[3] !=# '.' 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, 'sub': sub})
call add(unstaged, {'type': 'File', 'status': get({'C':'M','M':'?','U':'?'}, matchstr(sub, 'S\.*\zs[CMU]'), line[3]), 'filename': file})
endif endif
endif endif
let i += 1 let i += 1
@@ -1697,12 +1697,12 @@ function! fugitive#BufReadStatus() abort
let i += 1 let i += 1
endif endif
if line[0] !~# '[ ?!#]' 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 endif
if line[0:1] ==# '??' if line[0:1] ==# '??'
call add(untracked, {'type': 'File', 'status': line[1], 'filename': files}) call add(untracked, {'type': 'File', 'status': line[1], 'filename': files})
elseif line[1] !~# '[ !#]' 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 endif
endwhile endwhile
endif endif
@@ -3074,6 +3074,20 @@ function! s:StageDelete(lnum1, lnum2, count) abort
if empty(info.paths) if empty(info.paths)
continue continue
endif 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' if info.status ==# 'D'
let undo = 'Gremove' let undo = 'Gremove'
elseif info.paths[0] =~# '/$' elseif info.paths[0] =~# '/$'