diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index aac79c6e93..f9749e4a88 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1700,15 +1700,38 @@ function! s:ReplaceCmd(cmd) abort endif endfunction -function! s:QueryLog(refspec) abort - let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%s', a:refspec, '--'])[0] +function! s:IgnoreRefs(refs, refsToIgnore) abort + function! ShouldPreserveRef(refsToIgnore, index, ref) abort + return index(a:refsToIgnore, a:ref) == -1 + endfunction + + let refs = split(a:refs[1:-2], ", ") + let refs = filter(refs, function('ShouldPreserveRef', [a:refsToIgnore])) + + if len(a:refs) == 0 + return '' + endif + + return '(' . join(refs, ", ") . ')' +endfunction + +function! s:QueryLog(refspec, refToIgnore) abort + let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%d%x09%s', a:refspec, '--'])[0] call map(lines, 'split(v:val, "\t", 1)') - call map(lines, '{"type": "Log", "commit": v:val[0], "subject": join(v:val[1 : -1], "\t")}') + let refsToIgnore = [a:refToIgnore, 'HEAD'] + + function! HandleRefs(refsToIgnore, refs) abort + return s:IgnoreRefs(trim(a:refs), a:refsToIgnore) + endfunction + + call map(lines, '{"type": "Log", "commit": v:val[0], "refs": ' . string(function('HandleRefs', [refsToIgnore])) . '(v:val[1]), "subject": join(v:val[2 : -1], "\t")}') return lines endfunction function! s:FormatLog(dict) abort - return a:dict.commit . ' ' . a:dict.subject + setlocal conceallevel=3 + setlocal concealcursor=nc + return a:dict.commit . ' ' . ((len(a:dict.refs) > 0) ? ("\x1f" . a:dict.refs . ' ') : '') . a:dict.subject endfunction function! s:FormatRebase(dict) abort @@ -1996,16 +2019,16 @@ function! fugitive#BufReadStatus() abort let staged_end = len(staged) ? line('$') : 0 if len(pull) && get(props, 'branch.ab') !~# ' -0$' - call s:AddSection('Unpulled from ' . pull, s:QueryLog(head . '..' . pull)) + call s:AddSection('Unpulled from ' . pull, s:QueryLog(head . '..' . pull, pull)) endif if len(push) && push !=# pull - call s:AddSection('Unpulled from ' . push, s:QueryLog(head . '..' . push)) + call s:AddSection('Unpulled from ' . push, s:QueryLog(head . '..' . push, push)) endif if len(pull) && push !=# pull - call s:AddSection('Unpushed to ' . pull, s:QueryLog(pull . '..' . head)) + call s:AddSection('Unpushed to ' . pull, s:QueryLog(pull . '..' . head, pull)) endif if len(push) && !(push ==# pull && get(props, 'branch.ab') =~# '^+0 ') - call s:AddSection('Unpushed to ' . push, s:QueryLog(push . '..' . head)) + call s:AddSection('Unpushed to ' . push, s:QueryLog(push . '..' . head, push)) endif setlocal nomodified readonly noswapfile diff --git a/syntax/fugitive.vim b/syntax/fugitive.vim index e84eba4e76..7425e855b3 100644 --- a/syntax/fugitive.vim +++ b/syntax/fugitive.vim @@ -23,8 +23,10 @@ syn match fugitiveDone /^done\>/ contained containedin=@fugitiveSection nextgrou syn match fugitiveStop /^stop\>/ contained containedin=@fugitiveSection nextgroup=fugitiveHash skipwhite syn match fugitiveModifier /^[MADRCU?]\{1,2} / contained containedin=@fugitiveSection syn match fugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@