Improve :Gclog window title

This commit is contained in:
Tim Pope
2020-01-05 00:36:36 -05:00
parent 726fdf1c94
commit 6d011f1ea5

View File

@@ -3953,32 +3953,36 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
endif endif
if a:line1 == 0 && a:count if a:line1 == 0 && a:count
let path = fugitive#Path(bufname(a:count), '/', dir) let path = fugitive#Path(bufname(a:count), '/', dir)
let titlepre = ':0,' . a:count
elseif a:count >= 0 elseif a:count >= 0
let path = fugitive#Path(@%, '/', dir) let path = fugitive#Path(@%, '/', dir)
let titlepre = a:count == 0 ? ':0,' . bufnr('') : ':'
else else
let titlepre = ':'
let path = '' let path = ''
endif endif
let range = '' let range = ''
let extra = [] let extra_args = []
let extra_paths = []
let state = {'context': 'init', 'child_found': 0, 'queue': [], 'follow': 0} let state = {'context': 'init', 'child_found': 0, 'queue': [], 'follow': 0}
if path =~# '^/\.git\%(/\|$\)\|^$' if path =~# '^/\.git\%(/\|$\)\|^$'
let path = '' let path = ''
elseif a:line1 == 0 elseif a:line1 == 0
let range = "0," . (a:count ? a:count : bufnr('')) let range = "0," . (a:count ? a:count : bufnr(''))
let extra = ['.' . path] let extra_paths = ['.' . path]
if (empty(paths) || paths ==# ['--']) && !s:HasOpt(args, '--no-follow') if (empty(paths) || paths ==# ['--']) && !s:HasOpt(args, '--no-follow')
let state.follow = 1 let state.follow = 1
if !s:HasOpt(args, '--follow') if !s:HasOpt(args, '--follow')
call insert(args, '--follow') call insert(extra_args, '--follow')
endif endif
if !s:HasOpt(args, '--summary') if !s:HasOpt(args, '--summary')
call insert(args, '--summary') call insert(extra_args, '--summary')
let state.ignore_summary = 1 let state.ignore_summary = 1
endif endif
endif endif
elseif a:count > 0 elseif a:count > 0
if !s:HasOpt(args, '--merges', '--no-merges') if !s:HasOpt(args, '--merges', '--no-merges')
call insert(args, '--no-merges') call insert(extra_args, '--no-merges')
endif endif
call add(args, '-L' . a:line1 . ',' . a:count . ':' . path[1:-1]) call add(args, '-L' . a:line1 . ',' . a:count . ':' . path[1:-1])
endif endif
@@ -3988,7 +3992,7 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
call add(args, owner) call add(args, owner)
endif endif
endif endif
if empty(extra) if empty(extra_paths)
let path = '' let path = ''
endif endif
if s:HasOpt(args, '-g', '--walk-reflogs') if s:HasOpt(args, '-g', '--walk-reflogs')
@@ -4004,10 +4008,10 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
endif endif
call extend(cmd, call extend(cmd,
\ ['--no-color', '--no-ext-diff', '--pretty=format:fugitive ' . format] + \ ['--no-color', '--no-ext-diff', '--pretty=format:fugitive ' . format] +
\ args + paths + extra) \ args + extra_args + paths + extra_paths)
let state.target = path let state.target = path
let title = (listnr < 0 ? ':Gclog ' : ':Gllog ') . s:fnameescape(args + paths) let title = titlepre . (listnr < 0 ? 'Gclog ' : 'Gllog ') . s:fnameescape(args + paths)
if empty(paths + extra) && empty(a:type) && len(s:Relative('/')) if empty(paths + extra_paths) && empty(a:type) && len(s:Relative('/'))
let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after
endif endif
return s:QuickfixStream(listnr, title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after return s:QuickfixStream(listnr, title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after