From 24d4098ceb296db3dd1b1697abfc742a1d4ee6de Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 22 Jul 2014 20:45:54 -0400 Subject: [PATCH] Change arity of browse API It's debatable whether the repo object should be passed at all, so let's not commit to a positional parameter for it. References #445. --- plugin/fugitive.vim | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index d451161..3166721 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -2176,7 +2176,8 @@ function! s:Browse(bang,line1,count,...) abort endif for Handler in g:fugitive_browse_handlers - let url = call(Handler, [s:repo(), { + let url = call(Handler, [{ + \ 'repo': s:repo(), \ 'remote': raw, \ 'revision': rev, \ 'commit': commit, @@ -2206,7 +2207,7 @@ function! s:Browse(bang,line1,count,...) abort endtry endfunction -function! s:github_url(repo, opts, ...) abort +function! s:github_url(opts, ...) abort if a:0 || type(a:opts) != type({}) return '' endif @@ -2226,7 +2227,7 @@ function! s:github_url(repo, opts, ...) abort let root = 'https://' . s:sub(repo,':','/') endif if path =~# '^\.git/refs/heads/' - let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] + let branch = a:opts.repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] if branch ==# '' return root . '/commits/' . path[16:-1] else @@ -2242,8 +2243,8 @@ function! s:github_url(repo, opts, ...) abort if a:opts.revision =~# '^[[:alnum:]._-]\+:' let commit = matchstr(a:opts.revision,'^[^:]*') elseif a:opts.commit =~# '^\d\=$' - let local = matchstr(a:repo.head_ref(),'\ '.tmp + silent execute 'write !'.a:opts.repo.git_command('hash-object','-w','--stdin').' > '.tmp let url .= ';h=' . readfile(tmp)[0] else try - let url .= ';h=' . a:repo.rev_parse((a:opts.commit == '' ? 'HEAD' : ':' . a:opts.commit) . ':' . a:opts.path) + let url .= ';h=' . a:opts.repo.rev_parse((a:opts.commit == '' ? 'HEAD' : ':' . a:opts.commit) . ':' . a:opts.path) catch /^fugitive:/ call s:throw('fugitive: cannot browse uncommitted file') endtry endif - let root .= ';hb=' . matchstr(a:repo.head_ref(),'[^ ]\+$') + let root .= ';hb=' . matchstr(a:opts.repo.head_ref(),'[^ ]\+$') endif if a:opts.path !=# '' let url .= ';f=' . a:opts.path