Skip to content

Commit

Permalink
Add commit hash to the default fugitive display format
Browse files Browse the repository at this point in the history
- Improve readability of the pretty format string for the `git show`
  command.

- Include `commit %H` to the `git show` output, which is one of the most
  useful and important information for a git commit being displayed.
  • Loading branch information
wookayin committed Mar 19, 2024
1 parent 8d4e8d4 commit 018ac73
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion autoload/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3193,7 +3193,19 @@ function! fugitive#BufReadCmd(...) abort
if b:fugitive_display_format
call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev])
else
call s:ReplaceCmd([dir, '-c', 'diff.noprefix=false', '-c', 'log.showRoot=false', 'show', '--no-color', '-m', '--first-parent', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev])
let s:format = substitute(join([
\ 'commit %H',
\ 'tree %T',
\ 'parent %P',
\ 'author %an <%ae> %ad',
\ 'committer %cn <%ce> %cd',
\ 'encoding %e',
\ '',
\ '%s',
\ '',
\ '%b'
\], '%n'), ' ', '%x20', 'g')
call s:ReplaceCmd([dir, '-c', 'diff.noprefix=false', '-c', 'log.showRoot=false', 'show', '--no-color', '-m', '--first-parent', '--pretty=' . s:format, rev])
keepjumps 1
keepjumps call search('^parent ')
if getline('.') ==# 'parent '
Expand Down

0 comments on commit 018ac73

Please sign in to comment.