Skip to content

Commit 8797e3e

Browse files
committed
Show refs in log in Gstatus
Display refs (the output of %d from git log's format=pretty) next to commit summaries in Gstatus. Use basic syntax highlighting for all refs. Use a special marker and concealing to avoid false-positives when commit subjects begin with parentheses.
1 parent 156dbcd commit 8797e3e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

autoload/fugitive.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,14 +1701,16 @@ function! s:ReplaceCmd(cmd) abort
17011701
endfunction
17021702

17031703
function! s:QueryLog(refspec) abort
1704-
let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%s', a:refspec, '--'])[0]
1704+
let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%d%x09%s', a:refspec, '--'])[0]
17051705
call map(lines, 'split(v:val, "\t", 1)')
1706-
call map(lines, '{"type": "Log", "commit": v:val[0], "subject": join(v:val[1 : -1], "\t")}')
1706+
call map(lines, '{"type": "Log", "commit": v:val[0], "refs": trim(v:val[1]), "subject": join(v:val[2 : -1], "\t")}')
17071707
return lines
17081708
endfunction
17091709

17101710
function! s:FormatLog(dict) abort
1711-
return a:dict.commit . ' ' . a:dict.subject
1711+
setlocal conceallevel=3
1712+
setlocal concealcursor=nc
1713+
return a:dict.commit . ' ' . ((len(a:dict.refs) > 0) ? ("\x1f" . a:dict.refs . ' ') : '') . a:dict.subject
17121714
endfunction
17131715

17141716
function! s:FormatRebase(dict) abort

syntax/fugitive.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ syn match fugitiveDone /^done\>/ contained containedin=@fugitiveSection nextgrou
2323
syn match fugitiveStop /^stop\>/ contained containedin=@fugitiveSection nextgroup=fugitiveHash skipwhite
2424
syn match fugitiveModifier /^[MADRCU?]\{1,2} / contained containedin=@fugitiveSection
2525
syn match fugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@<!/ contained
26-
syn match fugitiveHash /^\x\{4,\}\S\@!/ contained containedin=@fugitiveSection
26+
syn match fugitiveHash /^\x\{4,\}\S\@!/ contained containedin=@fugitiveSection nextgroup=fugitiveRefsConcealedMarker skipwhite
2727
syn match fugitiveHash /\S\@<!\x\{4,\}\S\@!/ contained
28+
syn match fugitiveRefsConcealedMarker "\%x1f" contained nextgroup=fugitiveRefs conceal
29+
syn match fugitiveRefs /([^)]\+)/hs=s+1,he=e-1 contained
2830

2931
syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=@fugitiveDiff containedin=@fugitiveSection fold
3032

@@ -51,6 +53,7 @@ hi def link fugitiveStagedModifier Typedef
5153
hi def link fugitiveInstruction Type
5254
hi def link fugitiveStop Function
5355
hi def link fugitiveHash Identifier
56+
hi def link fugitiveRefs Function
5457
hi def link fugitiveSymbolicRef Function
5558
hi def link fugitiveCount Number
5659

0 commit comments

Comments
 (0)