From eb4d75efb621870393fe174e1647c585544eb732 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 19 Feb 2021 18:47:13 -0500 Subject: [PATCH] Fix :Gedit worktree-file Closes https://github.com/tpope/vim-fugitive/issues/1679 References https://github.com/tpope/vim-fugitive/issues/1667 --- autoload/fugitive.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 2de6192..1a2215f 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1010,8 +1010,15 @@ function! fugitive#Find(object, ...) abort endif if commit !~# '^[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 - let f = 'fugitive://' . dir . '//' . (len(commit) ? commit : repeat('0', 40)) . file endif endif return FugitiveVimPath(f)