From abe29d48917b349f082684fa5c00ea5b741f00f1 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 17 Jun 2022 13:15:29 -0400 Subject: [PATCH] Restore .git_dir on fugitive#repo() This will enable functions like FugitiveFind() to use fugitive#repo() as the optional second parameter, which should make transitioning to the new API a bit easier to do incrementally. --- autoload/fugitive.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0505c18..3fbe727 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1553,7 +1553,11 @@ endfunction let s:repo_prototype = {} function! fugitive#repo(...) abort - return copy(s:repo_prototype) + let dir = a:0 ? s:GitDir(a:1) : (len(s:GitDir()) ? s:GitDir() : FugitiveExtractGitDir(expand('%:p'))) + if dir !=# '' + return extend({'git_dir': dir, 'fugitive_dir': dir}, s:repo_prototype, 'keep') + endif + throw 'fugitive: not a Git repository' endfunction function! s:repo_dir(...) dict abort