Fix :Gedit worktree-file

Closes https://github.com/tpope/vim-fugitive/issues/1679

References https://github.com/tpope/vim-fugitive/issues/1667
This commit is contained in:
Tim Pope
2021-02-19 18:47:13 -05:00
parent 0a35937003
commit eb4d75efb6

View File

@@ -1010,8 +1010,15 @@ function! fugitive#Find(object, ...) abort
endif endif
if commit !~# '^[0-9a-f]\{40,\}$' if commit !~# '^[0-9a-f]\{40,\}$'
let commit = matchstr(s:ChompDefault('', [dir, 'rev-parse', '--verify', commit . (len(file) ? '^{}' : ''), '--']), '\<[0-9a-f]\{40,\}\>') let commit = matchstr(s:ChompDefault('', [dir, 'rev-parse', '--verify', commit . (len(file) ? '^{}' : ''), '--']), '\<[0-9a-f]\{40,\}\>')
if empty(commit) && len(file)
let commit = repeat('0', 40)
endif
endif
if len(commit)
let f = 'fugitive://' . dir . '//' . commit . file
else
let f = base . '/' . substitute(rev, '^:/:\=\|^[^:]\+:', '', '')
endif endif
let f = 'fugitive://' . dir . '//' . (len(commit) ? commit : repeat('0', 40)) . file
endif endif
endif endif
return FugitiveVimPath(f) return FugitiveVimPath(f)