From 018ac73b92fda6c8ff06d8075cce533febeff0fb Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 7 Dec 2023 05:42:22 -0500 Subject: [PATCH] Add commit hash to the default fugitive display format - 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. --- autoload/fugitive.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index c9c7895ff0..8d89812cf4 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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 '