mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 05:13:53 -05:00
Simplify conditional around :GBrowse line number computation
This is solely to improve the readability of upcoming diffs.
This commit is contained in:
@@ -7369,27 +7369,24 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, ...) abor
|
||||
let line1 = a:count > 0 && type ==# 'blob' ? a:line1 : 0
|
||||
let line2 = a:count > 0 && type ==# 'blob' ? a:count : 0
|
||||
if empty(commit) && path !~# '^\.git/'
|
||||
if a:count < 0 && !empty(merge)
|
||||
if a:count < 0
|
||||
let commit = merge
|
||||
else
|
||||
let commit = ''
|
||||
if len(merge)
|
||||
let owner = s:Owner(@%, dir)
|
||||
let commit = s:ChompDefault('', ['merge-base', 'refs/remotes/' . remote . '/' . merge, empty(owner) ? '@' : owner, '--'], dir)
|
||||
if line2 > 0 && empty(arg) && commit =~# '^\x\{40,\}$'
|
||||
let blame_list = tempname()
|
||||
call writefile([commit, ''], blame_list, 'b')
|
||||
let blame_in = tempname()
|
||||
silent exe 'noautocmd keepalt %write' blame_in
|
||||
let [blame, exec_error] = s:LinesError(['-c', 'blame.coloring=none', 'blame', '--contents', blame_in, '-L', line1.','.line2, '-S', blame_list, '-s', '--show-number', './' . path], dir)
|
||||
if !exec_error
|
||||
let blame_regex = '^\^\x\+\s\+\zs\d\+\ze\s'
|
||||
if get(blame, 0) =~# blame_regex && get(blame, -1) =~# blame_regex
|
||||
let line1 = +matchstr(blame[0], blame_regex)
|
||||
let line2 = +matchstr(blame[-1], blame_regex)
|
||||
else
|
||||
throw "fugitive: can't browse to uncommitted change"
|
||||
endif
|
||||
elseif len(merge)
|
||||
let owner = s:Owner(@%, dir)
|
||||
let commit = s:ChompDefault('', ['merge-base', 'refs/remotes/' . remote . '/' . merge, empty(owner) ? '@' : owner, '--'], dir)
|
||||
if line2 > 0 && empty(arg) && commit =~# '^\x\{40,\}$'
|
||||
let blame_list = tempname()
|
||||
call writefile([commit, ''], blame_list, 'b')
|
||||
let blame_in = tempname()
|
||||
silent exe 'noautocmd keepalt %write' blame_in
|
||||
let [blame, exec_error] = s:LinesError(['-c', 'blame.coloring=none', 'blame', '--contents', blame_in, '-L', line1.','.line2, '-S', blame_list, '-s', '--show-number', './' . path], dir)
|
||||
if !exec_error
|
||||
let blame_regex = '^\^\x\+\s\+\zs\d\+\ze\s'
|
||||
if get(blame, 0) =~# blame_regex && get(blame, -1) =~# blame_regex
|
||||
let line1 = +matchstr(blame[0], blame_regex)
|
||||
let line2 = +matchstr(blame[-1], blame_regex)
|
||||
else
|
||||
throw "fugitive: can't browse to uncommitted change"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user