mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
Avoid repeat config retrieval in :GBrowse
This commit is contained in:
@@ -1121,7 +1121,7 @@ endfunction
|
|||||||
|
|
||||||
call s:add_methods('config', ['GetAll', 'Get', 'GetRegexp'])
|
call s:add_methods('config', ['GetAll', 'Get', 'GetRegexp'])
|
||||||
|
|
||||||
function! s:Remote(dir) abort
|
function! s:RemoteDefault(dir) abort
|
||||||
let head = FugitiveHead(0, a:dir)
|
let head = FugitiveHead(0, a:dir)
|
||||||
let remote = len(head) ? FugitiveConfigGet('branch.' . head . '.remote', a:dir) : ''
|
let remote = len(head) ? FugitiveConfigGet('branch.' . head . '.remote', a:dir) : ''
|
||||||
let i = 10
|
let i = 10
|
||||||
@@ -1311,10 +1311,10 @@ function! fugitive#RemoteUrl(...) abort
|
|||||||
let config = fugitive#Config()
|
let config = fugitive#Config()
|
||||||
endif
|
endif
|
||||||
if empty(args) || args[0] =~# '^:'
|
if empty(args) || args[0] =~# '^:'
|
||||||
let url = s:Remote(config)
|
let url = s:RemoteDefault(config)
|
||||||
elseif args[0] =~# '^\.\=$'
|
elseif args[0] =~# '^\.\=$'
|
||||||
call remove(args, 0)
|
call remove(args, 0)
|
||||||
let url = s:Remote(config)
|
let url = s:RemoteDefault(config)
|
||||||
else
|
else
|
||||||
let url = remove(args, 0)
|
let url = remove(args, 0)
|
||||||
endif
|
endif
|
||||||
@@ -7177,6 +7177,7 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
let type = 'blob'
|
let type = 'blob'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
let config = fugitive#Config(dir)
|
||||||
if type ==# 'tree' && !empty(path)
|
if type ==# 'tree' && !empty(path)
|
||||||
let path = s:sub(path, '/\=$', '/')
|
let path = s:sub(path, '/\=$', '/')
|
||||||
endif
|
endif
|
||||||
@@ -7208,13 +7209,13 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
let branch = FugitiveHead(0, dir)
|
let branch = FugitiveHead(0, dir)
|
||||||
endif
|
endif
|
||||||
if !empty(branch)
|
if !empty(branch)
|
||||||
let r = FugitiveConfigGet('branch.'.branch.'.remote', dir)
|
let r = FugitiveConfigGet('branch.'.branch.'.remote', config)
|
||||||
let m = FugitiveConfigGet('branch.'.branch.'.merge', dir)[11:-1]
|
let m = FugitiveConfigGet('branch.'.branch.'.merge', config)[11:-1]
|
||||||
if r ==# '.' && !empty(m)
|
if r ==# '.' && !empty(m)
|
||||||
let r2 = FugitiveConfigGet('branch.'.m.'.remote', dir)
|
let r2 = FugitiveConfigGet('branch.'.m.'.remote', config)
|
||||||
if r2 !~# '^\.\=$'
|
if r2 !~# '^\.\=$'
|
||||||
let r = r2
|
let r = r2
|
||||||
let m = FugitiveConfigGet('branch.'.m.'.merge', dir)[11:-1]
|
let m = FugitiveConfigGet('branch.'.m.'.merge', config)[11:-1]
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if empty(remote)
|
if empty(remote)
|
||||||
@@ -7222,7 +7223,7 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
endif
|
endif
|
||||||
if r ==# '.' || r ==# remote
|
if r ==# '.' || r ==# remote
|
||||||
let remote_ref = 'refs/remotes/' . remote . '/' . branch
|
let remote_ref = 'refs/remotes/' . remote . '/' . branch
|
||||||
if FugitiveConfigGet('push.default', dir) ==# 'upstream' ||
|
if FugitiveConfigGet('push.default', config) ==# 'upstream' ||
|
||||||
\ !filereadable(FugitiveFind('.git/' . remote_ref, dir)) && empty(s:ChompDefault('', ['rev-parse', '--verify', remote_ref, '--'], dir))
|
\ !filereadable(FugitiveFind('.git/' . remote_ref, dir)) && empty(s:ChompDefault('', ['rev-parse', '--verify', remote_ref, '--'], dir))
|
||||||
let merge = m
|
let merge = m
|
||||||
if path =~# '^\.git/refs/heads/.'
|
if path =~# '^\.git/refs/heads/.'
|
||||||
@@ -7278,12 +7279,12 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if empty(remote) || remote ==# '.'
|
if empty(remote) || remote ==# '.'
|
||||||
let remote = s:Remote(dir)
|
let remote = s:RemoteDefault(config)
|
||||||
endif
|
endif
|
||||||
if remote =~# ':'
|
if remote =~# ':'
|
||||||
let remote_url = remote
|
let remote_url = remote
|
||||||
else
|
else
|
||||||
let remote_url = fugitive#RemoteUrl(remote, dir)
|
let remote_url = fugitive#RemoteUrl(remote, config)
|
||||||
endif
|
endif
|
||||||
let raw = empty(remote_url) ? remote : remote_url
|
let raw = empty(remote_url) ? remote : remote_url
|
||||||
let git_dir = s:GitDir(dir)
|
let git_dir = s:GitDir(dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user