From 3485e22a0a7346bca93a9194ff9865d99ecdba64 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 17 Jun 2022 14:07:31 -0400 Subject: [PATCH] Restore popular fugitive#repo() functions I'm quite eager to kill the "chomp" functions, as they're the last use of system(). However, the successor, FugitiveExecute(), is only a year old, and isn't a drop-in replacement. So let's bring them back for awhile to avoid the need for a massive conditional to give backwards compatibility. The rest are pretty benign to support, so I guess they can stick around until the band-aid is officially ripped off. --- autoload/fugitive.vim | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 167cfb6..8b5b399 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1598,11 +1598,20 @@ function! fugitive#repo(...) abort endfunction function! s:repo_dir(...) dict abort - throw 'fugitive: fugitive#repo().dir() has been replaced by FugitiveGitDir()' + if !a:0 + return self.git_dir + endif + throw 'fugitive: fugitive#repo().dir("...") has been replaced by FugitiveFind(".git/...")' endfunction function! s:repo_tree(...) dict abort - throw 'fugitive: fugitive#repo().tree() has been replaced by FugitiveFind(":/")' + let tree = s:Tree(self.git_dir) + if empty(tree) + throw 'fugitive: no work tree' + elseif !a:0 + return tree + endif + throw 'fugitive: fugitive#repo().tree("...") has been replaced by FugitiveFind(":(top)...")' endfunction function! s:repo_bare() dict abort @@ -1628,11 +1637,11 @@ function! s:repo_git_command(...) dict abort endfunction function! s:repo_git_chomp(...) dict abort - throw 'fugitive: fugitive#repo().git_chomp(...) has been replaced by FugitiveExecute(...).stdout' + silent return substitute(system(fugitive#ShellCommand(a:000, self.git_dir)), '\n$', '', '') endfunction function! s:repo_git_chomp_in_tree(...) dict abort - throw 'fugitive: fugitive#repo().git_chomp_in_tree(...) has been replaced by FugitiveExecute(...).stdout' + return call(self.git_chomp, a:000, self) endfunction function! s:repo_rev_parse(rev) dict abort @@ -1642,7 +1651,7 @@ endfunction call s:add_methods('repo',['git_command','git_chomp','git_chomp_in_tree','rev_parse']) function! s:repo_config(name) dict abort - throw 'fugitive: fugitive#repo().config(...) has been replaced by FugitiveConfigGet(...)' + return FugitiveConfigGet(a:name, self.git_dir) endfunction call s:add_methods('repo',['config'])