Change s:StageInfo() to use absolute paths like s:Selection()

This commit is contained in:
Tim Pope 2019-07-04 07:28:52 -04:00
parent 51c54138ba
commit c62d23bc18

View File

@ -2134,7 +2134,7 @@ function! s:StageInfo(...) abort
\ 'sigil': sigil, \ 'sigil': sigil,
\ 'offset': offset, \ 'offset': offset,
\ 'filename': text, \ 'filename': text,
\ 'paths': reverse(split(text, ' -> ')), \ 'paths': map(reverse(split(text, ' -> ')), 's:Tree() . "/" . v:val'),
\ 'commit': matchstr(getline(lnum), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze '), \ 'commit': matchstr(getline(lnum), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze '),
\ 'status': matchstr(getline(lnum), '^[A-Z?]\ze \|^\%(\x\x\x\)\@!\l\+\ze [0-9a-f]'), \ 'status': matchstr(getline(lnum), '^[A-Z?]\ze \|^\%(\x\x\x\)\@!\l\+\ze [0-9a-f]'),
\ 'index': index} \ 'index': index}
@ -2454,11 +2454,11 @@ endfunction
function! s:StageDiffEdit() abort function! s:StageDiffEdit() abort
let info = s:StageInfo(line('.')) let info = s:StageInfo(line('.'))
let arg = (empty(info.paths) ? '.' : info.paths[0]) let arg = (empty(info.paths) ? s:Tree() : info.paths[0])
if info.section ==# 'Staged' if info.section ==# 'Staged'
return 'Git! diff --no-ext-diff --cached '.s:shellesc(arg) return 'Git! diff --no-ext-diff --cached '.s:shellesc(arg)
elseif info.status ==# '?' elseif info.status ==# '?'
call s:TreeChomp('add', '--intent-to-add', './' . arg) call s:TreeChomp('add', '--intent-to-add', '--', arg)
return s:ReloadStatus() return s:ReloadStatus()
else else
return 'Git! diff --no-ext-diff '.s:shellesc(arg) return 'Git! diff --no-ext-diff '.s:shellesc(arg)
@ -2656,9 +2656,9 @@ function! s:StagePatch(lnum1,lnum2) abort
endif endif
execute lnum execute lnum
if info.section ==# 'Staged' if info.section ==# 'Staged'
let reset += info.paths let reset += split(info.filename, ' -> ')
elseif info.status !~# '^D' elseif info.status !~# '^D'
let add += info.paths let add += split(info.filename, ' -> ')
endif endif
endfor endfor
try try