Enable readable editing of *index*.lock
Among other things, this means running :Gstatus when $GIT_INDEX_FILE is set (e.g., when git commit is running) shows a more revealing filename.
This commit is contained in:
parent
93bd4c8944
commit
6eaa4604ff
@ -159,7 +159,11 @@ function! s:repo_translate(spec) dict abort
|
|||||||
elseif a:spec =~# '^:[0-3]:'
|
elseif a:spec =~# '^:[0-3]:'
|
||||||
return 'fugitive://'.self.dir().'//'.a:spec[1].'/'.a:spec[3:-1]
|
return 'fugitive://'.self.dir().'//'.a:spec[1].'/'.a:spec[3:-1]
|
||||||
elseif a:spec ==# ':'
|
elseif a:spec ==# ':'
|
||||||
return self.dir('index')
|
if $GIT_INDEX_FILE =~# '/[^/]*index[^/]*\.lock$' && fnamemodify($GIT_INDEX_FILE,':p')[0:strlen(s:repo().dir())] ==# s:repo().dir('') && filereadable($GIT_INDEX_FILE)
|
||||||
|
return fnamemodify($GIT_INDEX_FILE,':p')
|
||||||
|
else
|
||||||
|
return self.dir('index')
|
||||||
|
endif
|
||||||
elseif a:spec =~# '^:/'
|
elseif a:spec =~# '^:/'
|
||||||
let ref = self.rev_parse(matchstr(a:spec,'.[^:]*'))
|
let ref = self.rev_parse(matchstr(a:spec,'.[^:]*'))
|
||||||
return 'fugitive://'.self.dir().'//'.ref
|
return 'fugitive://'.self.dir().'//'.ref
|
||||||
@ -1045,22 +1049,27 @@ endfunction
|
|||||||
|
|
||||||
function! s:BufReadIndex()
|
function! s:BufReadIndex()
|
||||||
if !exists('b:fugitive_display_format')
|
if !exists('b:fugitive_display_format')
|
||||||
let b:fugitive_display_format = +getbufvar('#','fugitive_display_format')
|
let b:fugitive_display_format = filereadable(expand('<afile>').'.lock')
|
||||||
endif
|
endif
|
||||||
let b:fugitive_display_format = b:fugitive_display_format % 2
|
let b:fugitive_display_format = b:fugitive_display_format % 2
|
||||||
let b:fugitive_type = 'index'
|
let b:fugitive_type = 'index'
|
||||||
try
|
try
|
||||||
let b:git_dir = s:repo().dir()
|
let b:git_dir = s:repo().dir()
|
||||||
setlocal noro ma
|
setlocal noro ma
|
||||||
|
if fnamemodify($GIT_INDEX_FILE !=# '' ? $GIT_INDEX_FILE : b:git_dir . '/index', ':p') ==# expand('<amatch>:p')
|
||||||
|
let indexspec = ''
|
||||||
|
else
|
||||||
|
let indexspec = 'GIT_INDEX_FILE='.expand('<afile>').' '
|
||||||
|
endif
|
||||||
if b:fugitive_display_format
|
if b:fugitive_display_format
|
||||||
call s:ReplaceCmd(s:repo().git_command('ls-files','--stage'))
|
call s:ReplaceCmd(indexspec.s:repo().git_command('ls-files','--stage'))
|
||||||
set ft=git nospell
|
set ft=git nospell
|
||||||
else
|
else
|
||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||||
let dir = getcwd()
|
let dir = getcwd()
|
||||||
try
|
try
|
||||||
execute cd.' `=s:repo().tree()`'
|
execute cd.' `=s:repo().tree()`'
|
||||||
call s:ReplaceCmd(s:repo().git_command('status'))
|
call s:ReplaceCmd(indexspec.s:repo().git_command('status'))
|
||||||
finally
|
finally
|
||||||
execute cd.' `=dir`'
|
execute cd.' `=dir`'
|
||||||
endtry
|
endtry
|
||||||
@ -1208,6 +1217,7 @@ endfunction
|
|||||||
augroup fugitive_files
|
augroup fugitive_files
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufReadCmd *.git/index exe s:BufReadIndex()
|
autocmd BufReadCmd *.git/index exe s:BufReadIndex()
|
||||||
|
autocmd BufReadCmd *.git/*index*.lock exe s:BufReadIndex()
|
||||||
autocmd FileReadCmd fugitive://**//[0-3]/** exe s:FileRead()
|
autocmd FileReadCmd fugitive://**//[0-3]/** exe s:FileRead()
|
||||||
autocmd BufReadCmd fugitive://**//[0-3]/** exe s:BufReadIndexFile()
|
autocmd BufReadCmd fugitive://**//[0-3]/** exe s:BufReadIndexFile()
|
||||||
autocmd BufWriteCmd fugitive://**//[0-3]/** exe s:BufWriteIndexFile()
|
autocmd BufWriteCmd fugitive://**//[0-3]/** exe s:BufWriteIndexFile()
|
||||||
|
Loading…
Reference in New Issue
Block a user